Class: Muddyit::OAuth
- Inherits:
-
Object
- Object
- Muddyit::OAuth
- Extended by:
- Forwardable
- Defined in:
- lib/muddyit/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
A new instance of OAuth.
-
#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
Returns a new instance of OAuth.
10 11 12 |
# File 'lib/muddyit/oauth.rb', line 10 def initialize(ctoken, csecret, ={}) @ctoken, @csecret, @consumer_options = ctoken, csecret, {} end |
Instance Attribute Details
#consumer_options ⇒ Object (readonly)
Returns the value of attribute consumer_options.
7 8 9 |
# File 'lib/muddyit/oauth.rb', line 7 def @consumer_options end |
#csecret ⇒ Object (readonly)
Returns the value of attribute csecret.
7 8 9 |
# File 'lib/muddyit/oauth.rb', line 7 def csecret @csecret end |
#ctoken ⇒ Object (readonly)
Returns the value of attribute ctoken.
7 8 9 |
# File 'lib/muddyit/oauth.rb', line 7 def ctoken @ctoken end |
Instance Method Details
#access_token ⇒ Object
36 37 38 |
# File 'lib/muddyit/oauth.rb', line 36 def access_token @access_token ||= ::OAuth::AccessToken.new(consumer, @atoken, @asecret) end |
#authorize_from_access(atoken, asecret) ⇒ Object
40 41 42 |
# File 'lib/muddyit/oauth.rb', line 40 def (atoken, asecret) @atoken, @asecret = atoken, asecret end |
#authorize_from_request(rtoken, rsecret) ⇒ Object
30 31 32 33 34 |
# File 'lib/muddyit/oauth.rb', line 30 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
14 15 16 |
# File 'lib/muddyit/oauth.rb', line 14 def consumer @consumer ||= ::OAuth::Consumer.new(@ctoken, @csecret, {:site => 'http://muddy.it'}.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 twitter should redirect to
26 27 28 |
# File 'lib/muddyit/oauth.rb', line 26 def request_token(={}) @request_token ||= consumer.get_request_token() end |
#set_callback_url(url) ⇒ Object
18 19 20 21 |
# File 'lib/muddyit/oauth.rb', line 18 def set_callback_url(url) clear_request_token request_token(:oauth_callback => url) end |