Module: LinkedIn::AuthorizationHelpers

Included in:
Client
Defined in:
lib/linked_in/authorization_helpers.rb

Instance Method Summary collapse

Instance Method Details

#access_tokenObject



32
33
34
# File 'lib/linked_in/authorization_helpers.rb', line 32

def access_token
  @access_token ||= ::OAuth::AccessToken.new(consumer, @atoken, @asecret)
end

#authorize_from_access(atoken, asecret) ⇒ Object



36
37
38
# File 'lib/linked_in/authorization_helpers.rb', line 36

def authorize_from_access(atoken, asecret)
  @atoken, @asecret = atoken, asecret
end

#authorize_from_request(rtoken, rsecret, verifier_or_pin) ⇒ Object

For web apps use params, for desktop apps, use the verifier is the pin that LinkedIn gives users.



26
27
28
29
30
# File 'lib/linked_in/authorization_helpers.rb', line 26

def authorize_from_request(rtoken, rsecret, verifier_or_pin)
  request_token = ::OAuth::RequestToken.new(consumer, rtoken, rsecret)
  access_token = request_token.get_access_token(:oauth_verifier => verifier_or_pin)
  @atoken, @asecret = access_token.token, access_token.secret
end

#consumerObject



5
6
7
8
9
10
# File 'lib/linked_in/authorization_helpers.rb', line 5

def consumer
  @consumer ||= begin
    options = { :site => 'https://api.linkedin.com' }.merge(@consumer_options)
    ::OAuth::Consumer.new(@ctoken, @csecret, options)
  end
end

#request_token(options = {}) ⇒ Object

Note: If using oauth with a web app, be sure to provide :oauth_callback. Options:

:oauth_callback => String, url that LinkedIn should redirect to


20
21
22
# File 'lib/linked_in/authorization_helpers.rb', line 20

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

#set_callback_url(url) ⇒ Object



12
13
14
15
# File 'lib/linked_in/authorization_helpers.rb', line 12

def set_callback_url(url)
  clear_request_token
  request_token(:oauth_callback => url)
end