Module: Activite::HTTP::OAuthClient

Included in:
Client
Defined in:
lib/activite/http/oauth.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  site:              'https://oauth.withings.com',
  proxy:              nil,
  request_token_path: '/account/request_token',
  authorize_path:     '/account/authorize',
  access_token_path:  '/account/access_token',
  scheme:             :query_string
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#consumer=(value) ⇒ Object

Sets the attribute consumer

Parameters:

  • value

    the value to set the attribute consumer to.



7
8
9
# File 'lib/activite/http/oauth.rb', line 7

def consumer=(value)
  @consumer = value
end

#consumer_keyObject

Returns the value of attribute consumer_key.



6
7
8
# File 'lib/activite/http/oauth.rb', line 6

def consumer_key
  @consumer_key
end

#consumer_secretObject

Returns the value of attribute consumer_secret.



6
7
8
# File 'lib/activite/http/oauth.rb', line 6

def consumer_secret
  @consumer_secret
end

#secretObject

Returns the value of attribute secret.



6
7
8
# File 'lib/activite/http/oauth.rb', line 6

def secret
  @secret
end

#tokenObject

Returns the value of attribute token.



6
7
8
# File 'lib/activite/http/oauth.rb', line 6

def token
  @token
end

Instance Method Details

#access_token(token, secret, options = {}) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/activite/http/oauth.rb', line 27

def access_token(token, secret, options = {})
  request_token = OAuth::RequestToken.new(consumer, token, secret)
  @access_token = request_token.get_access_token(options)
  @token = @access_token.token
  @secret = @access_token.secret
  @access_token
end

#authorize_url(token, secret, options = {}) ⇒ Object



22
23
24
25
# File 'lib/activite/http/oauth.rb', line 22

def authorize_url(token, secret, options = {})
  request_token = OAuth::RequestToken.new(consumer, token, secret)
  request_token.authorize_url(options)
end

#connected?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/activite/http/oauth.rb', line 39

def connected?
  !@access_token.nil?
end

#existing_access_token(token, secret) ⇒ Object



35
36
37
# File 'lib/activite/http/oauth.rb', line 35

def existing_access_token(token, secret)
  OAuth::AccessToken.new(consumer, token, secret)
end

#request_token(options = {}) ⇒ Object



18
19
20
# File 'lib/activite/http/oauth.rb', line 18

def request_token(options = {})
  consumer.get_request_token(options)
end