Class: AWeber::OAuth
- Inherits:
-
Object
- Object
- AWeber::OAuth
- Extended by:
- Forwardable
- Defined in:
- lib/aweber/oauth.rb
Instance Attribute Summary collapse
-
#callback_url ⇒ Object
Returns the value of attribute callback_url.
Instance Method Summary collapse
- #access_token ⇒ Object
-
#authorize_with_access(access_token_key, access_token_secret) ⇒ Object
Authorize with an Access Token key and secret you’ve previously retrieved via a user authentication.
-
#authorize_with_verifier(verifier) ⇒ Object
Get an Access Token from a Request Token using the
verifier
code. -
#clear_tokens ⇒ Object
Remove any active token instances and start over.
- #consumer ⇒ Object
-
#initialize(consumer_token, consumer_secret, options = {}) ⇒ OAuth
constructor
A new instance of OAuth.
-
#request_token(options = {}) ⇒ Object
Retrieve a Request Token or simply return it, if it already exists.
Constructor Details
#initialize(consumer_token, consumer_secret, options = {}) ⇒ OAuth
Returns a new instance of OAuth.
9 10 11 12 13 |
# File 'lib/aweber/oauth.rb', line 9 def initialize(consumer_token, consumer_secret, ={}) @consumer_token = consumer_token @consumer_secret = consumer_secret @callback_url = [:callback_url] end |
Instance Attribute Details
#callback_url ⇒ Object
Returns the value of attribute callback_url.
7 8 9 |
# File 'lib/aweber/oauth.rb', line 7 def callback_url @callback_url end |
Instance Method Details
#access_token ⇒ Object
46 47 48 49 |
# File 'lib/aweber/oauth.rb', line 46 def access_token @access_token ||= ::OAuth::AccessToken.new(consumer, @access_token_key, @access_token_secret) end |
#authorize_with_access(access_token_key, access_token_secret) ⇒ Object
Authorize with an Access Token key and secret you’ve previously retrieved via a user authentication.
57 58 59 60 |
# File 'lib/aweber/oauth.rb', line 57 def (access_token_key, access_token_secret) @access_token_key = access_token_key @access_token_secret = access_token_secret end |
#authorize_with_verifier(verifier) ⇒ Object
Get an Access Token from a Request Token using the verifier
code.
39 40 41 42 43 44 |
# File 'lib/aweber/oauth.rb', line 39 def (verifier) token = request_token.get_access_token(:oauth_verifier => verifier) @access_token_key = token.token @access_token_secret = token.secret access_token end |
#clear_tokens ⇒ Object
Remove any active token instances and start over
64 65 66 67 |
# File 'lib/aweber/oauth.rb', line 64 def clear_tokens @request_token = nil @access_token = nil end |
#consumer ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/aweber/oauth.rb', line 15 def consumer @consumer ||= ::OAuth::Consumer.new(@consumer_token, @consumer_secret, { :site => AWeber.auth_endpoint, :request_token_path => "/#{AWeber::AUTH_VERSION}/oauth/request_token", :authorize_path => "/#{AWeber::AUTH_VERSION}/oauth/authorize", :access_token_path => "/#{AWeber::AUTH_VERSION}/oauth/access_token", :scheme => :query_string }) end |
#request_token(options = {}) ⇒ Object
Retrieve a Request Token or simply return it, if it already exists.
29 30 31 |
# File 'lib/aweber/oauth.rb', line 29 def request_token(={}) @request_token ||= consumer.get_request_token() end |