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.
-
#request_token=(request_token) ⇒ Object
Set a Request Token.
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
51 52 53 54 |
# File 'lib/aweber/oauth.rb', line 51 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.
62 63 64 65 |
# File 'lib/aweber/oauth.rb', line 62 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.
44 45 46 47 48 49 |
# File 'lib/aweber/oauth.rb', line 44 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
69 70 71 72 |
# File 'lib/aweber/oauth.rb', line 69 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 |
#request_token=(request_token) ⇒ Object
Set a Request Token
@param [Request Token] request_token the oauth request token to be set.
34 35 36 |
# File 'lib/aweber/oauth.rb', line 34 def request_token=(request_token) @request_token = request_token end |