Class: AWeber::OAuth
- Inherits:
-
Object
- Object
- AWeber::OAuth
- Extended by:
- Forwardable
- Defined in:
- lib/aweber/oauth.rb
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.
7 8 9 10 |
# File 'lib/aweber/oauth.rb', line 7 def initialize(consumer_token, consumer_secret, ={}) @consumer_token = consumer_token @consumer_secret = consumer_secret end |
Instance Method Details
#access_token ⇒ Object
43 44 45 46 |
# File 'lib/aweber/oauth.rb', line 43 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.
54 55 56 57 |
# File 'lib/aweber/oauth.rb', line 54 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.
36 37 38 39 40 41 |
# File 'lib/aweber/oauth.rb', line 36 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
61 62 63 64 |
# File 'lib/aweber/oauth.rb', line 61 def clear_tokens @request_token = nil @access_token = nil end |
#consumer ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/aweber/oauth.rb', line 12 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.
26 27 28 |
# File 'lib/aweber/oauth.rb', line 26 def request_token(={}) @request_token ||= consumer.get_request_token() end |