Class: LinkedIn::OAuth
- Inherits:
-
Object
- Object
- LinkedIn::OAuth
- Extended by:
- Forwardable
- Defined in:
- lib/linked_in/oauth.rb
Overview
>> oauth = LinkedIn::OAuth.new(‘token’, ‘secret’)
> #<LinkedIn::OAuth:0x1021db048 …>
>> oauth.request_token.authorize_url
> “api.linkedin.com/uas/oauth/authorize?oauth_token=XXXX” # goto URL
>> oauth.authorize_from_request(oauth.request_token.token, oauth.request_token.secret, PIN) DONE
Constant Summary collapse
- SITE_URL =
'https://api.linkedin.com'
Instance Attribute Summary collapse
-
#consumer_options ⇒ Object
readonly
Returns the value of attribute consumer_options.
-
#csecret ⇒ Object
readonly
Returns the value of attribute csecret.
-
#ctoken ⇒ Object
readonly
Returns the value of attribute ctoken.
Instance Method Summary collapse
- #access_token ⇒ Object
- #authorize_from_access(atoken, asecret) ⇒ Object
-
#authorize_from_request(rtoken, rsecret, verifier_or_pin) ⇒ Object
For web apps use params, for desktop apps, use the verifier is the pin that twitter gives users.
- #consumer ⇒ Object
-
#initialize(ctoken, csecret, options = {}) ⇒ OAuth
constructor
Options.
-
#request_token(options = {}) ⇒ Object
Note: If using oauth with a web app, be sure to provide :oauth_callback.
- #set_callback_url(url) ⇒ Object
Constructor Details
#initialize(ctoken, csecret, options = {}) ⇒ OAuth
Options
18 19 20 21 22 23 24 25 26 |
# File 'lib/linked_in/oauth.rb', line 18 def initialize(ctoken, csecret, ={}) @ctoken = ctoken @csecret = csecret @consumer_options = { :request_token_path => "/uas/oauth/requestToken?oauth_callback=oob", :access_token_path => "/uas/oauth/accessToken", :authorize_path => "/uas/oauth/authorize" }.merge() end |
Instance Attribute Details
#consumer_options ⇒ Object (readonly)
Returns the value of attribute consumer_options.
15 16 17 |
# File 'lib/linked_in/oauth.rb', line 15 def @consumer_options end |
#csecret ⇒ Object (readonly)
Returns the value of attribute csecret.
15 16 17 |
# File 'lib/linked_in/oauth.rb', line 15 def csecret @csecret end |
#ctoken ⇒ Object (readonly)
Returns the value of attribute ctoken.
15 16 17 |
# File 'lib/linked_in/oauth.rb', line 15 def ctoken @ctoken end |
Instance Method Details
#access_token ⇒ Object
52 53 54 |
# File 'lib/linked_in/oauth.rb', line 52 def access_token @access_token ||= ::OAuth::AccessToken.new(consumer, @atoken, @asecret) end |
#authorize_from_access(atoken, asecret) ⇒ Object
56 57 58 |
# File 'lib/linked_in/oauth.rb', line 56 def (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 twitter gives users.
46 47 48 49 50 |
# File 'lib/linked_in/oauth.rb', line 46 def (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 |
#consumer ⇒ Object
28 29 30 |
# File 'lib/linked_in/oauth.rb', line 28 def consumer @consumer ||= ::OAuth::Consumer.new(@ctoken, @csecret, {:site => SITE_URL}.merge()) 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
40 41 42 |
# File 'lib/linked_in/oauth.rb', line 40 def request_token(={}) @request_token ||= consumer.get_request_token() end |
#set_callback_url(url) ⇒ Object
32 33 34 35 |
# File 'lib/linked_in/oauth.rb', line 32 def set_callback_url(url) clear_request_token request_token(:oauth_callback => url) end |