Class: Twitter::OAuth
- Inherits:
-
Object
- Object
- Twitter::OAuth
- Extended by:
- Forwardable
- Defined in:
- lib/twitter/oauth.rb
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) ⇒ Object
- #consumer ⇒ Object
-
#initialize(ctoken, csecret, options = {}) ⇒ OAuth
constructor
Options :sign_in => true to just sign in with twitter instead of doing oauth authorization (apiwiki.twitter.com/Sign-in-with-Twitter).
- #request_token ⇒ Object
Constructor Details
#initialize(ctoken, csecret, options = {}) ⇒ OAuth
Options
:sign_in => true to just sign in with twitter instead of doing oauth authorization
(http://apiwiki.twitter.com/Sign-in-with-Twitter)
11 12 13 14 15 16 17 |
# File 'lib/twitter/oauth.rb', line 11 def initialize(ctoken, csecret, ={}) @ctoken, @csecret, @consumer_options = ctoken, csecret, {} if [:sign_in] @consumer_options[:authorize_path] = '/oauth/authenticate' end end |
Instance Attribute Details
#consumer_options ⇒ Object (readonly)
Returns the value of attribute consumer_options.
6 7 8 |
# File 'lib/twitter/oauth.rb', line 6 def @consumer_options end |
#csecret ⇒ Object (readonly)
Returns the value of attribute csecret.
6 7 8 |
# File 'lib/twitter/oauth.rb', line 6 def csecret @csecret end |
#ctoken ⇒ Object (readonly)
Returns the value of attribute ctoken.
6 7 8 |
# File 'lib/twitter/oauth.rb', line 6 def ctoken @ctoken end |
Instance Method Details
#access_token ⇒ Object
33 34 35 |
# File 'lib/twitter/oauth.rb', line 33 def access_token @access_token ||= ::OAuth::AccessToken.new(consumer, @atoken, @asecret) end |
#authorize_from_access(atoken, asecret) ⇒ Object
37 38 39 |
# File 'lib/twitter/oauth.rb', line 37 def (atoken, asecret) @atoken, @asecret = atoken, asecret end |
#authorize_from_request(rtoken, rsecret) ⇒ Object
27 28 29 30 31 |
# File 'lib/twitter/oauth.rb', line 27 def (rtoken, rsecret) request_token = ::OAuth::RequestToken.new(consumer, rtoken, rsecret) access_token = request_token.get_access_token @atoken, @asecret = access_token.token, access_token.secret end |
#consumer ⇒ Object
19 20 21 |
# File 'lib/twitter/oauth.rb', line 19 def consumer @consumer ||= ::OAuth::Consumer.new(@ctoken, @csecret, {:site => 'http://twitter.com'}.merge()) end |
#request_token ⇒ Object
23 24 25 |
# File 'lib/twitter/oauth.rb', line 23 def request_token @request_token ||= consumer.get_request_token end |