Class: Powershop::OAuth
- Inherits:
-
Object
- Object
- Powershop::OAuth
- Defined in:
- lib/powershop/oauth.rb
Overview
based on OAuth implementation for Twitter Gem, github.com/jnunemaker/twitter/
Instance Attribute Summary collapse
-
#consumer ⇒ Object
Returns the value of attribute consumer.
Instance Method Summary collapse
- #access_token ⇒ Object
- #authorize_from_access(atoken, asecret) ⇒ Object
- #authorize_from_request(rtoken, rsecret, verifier_or_pin) ⇒ Object
-
#initialize(key, secret) ⇒ OAuth
constructor
A new instance of OAuth.
- #request_token(options = {}) ⇒ Object
Constructor Details
#initialize(key, secret) ⇒ OAuth
Returns a new instance of OAuth.
13 14 15 16 17 18 19 |
# File 'lib/powershop/oauth.rb', line 13 def initialize(key, secret) @consumer = ::OAuth::Consumer.new(key, secret, :site => API_BASE_URL, :request_token_path => "/external_api/oauth/request_token", :authorize_path => "/external_api/oauth/authorize", :access_token_path => "/external_api/oauth/access_token") end |
Instance Attribute Details
#consumer ⇒ Object
Returns the value of attribute consumer.
7 8 9 |
# File 'lib/powershop/oauth.rb', line 7 def consumer @consumer end |
Instance Method Details
#access_token ⇒ Object
35 36 37 |
# File 'lib/powershop/oauth.rb', line 35 def access_token @access_token ||= ::OAuth::AccessToken.new(consumer, @atoken, @asecret) end |
#authorize_from_access(atoken, asecret) ⇒ Object
39 40 41 |
# File 'lib/powershop/oauth.rb', line 39 def (atoken, asecret) @atoken, @asecret = atoken, asecret end |
#authorize_from_request(rtoken, rsecret, verifier_or_pin) ⇒ Object
29 30 31 32 33 |
# File 'lib/powershop/oauth.rb', line 29 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 |
#request_token(options = {}) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/powershop/oauth.rb', line 21 def request_token(={}) # default to Out-Of-Band unless an oauth callback is specified # NB: Powershop requires an OAuth callback, ref: [E908] [:oauth_callback] ||= "oob" @request_token ||= consumer.get_request_token() end |