Class: Contacts::OAuthConsumer
- Defined in:
- lib/contacts/oauth_consumer.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#request_token ⇒ Object
Returns the value of attribute request_token.
Attributes inherited from Consumer
Instance Method Summary collapse
- #authentication_url(target = self.return_url) ⇒ Object
- #authorize(params) ⇒ Object
-
#initialize(consumer_options, request_token_params) ⇒ OAuthConsumer
constructor
A new instance of OAuthConsumer.
- #initialize_serialized(data) ⇒ Object
- #serializable_data ⇒ Object
Methods inherited from Consumer
configuration, configuration_attribute, configure, #contacts, deserialize, #serialize
Constructor Details
#initialize(consumer_options, request_token_params) ⇒ OAuthConsumer
Returns a new instance of OAuthConsumer.
9 10 11 12 |
# File 'lib/contacts/oauth_consumer.rb', line 9 def initialize(, request_token_params) @consumer_options = @request_token_params = request_token_params end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
29 30 31 |
# File 'lib/contacts/oauth_consumer.rb', line 29 def access_token @access_token end |
#request_token ⇒ Object
Returns the value of attribute request_token.
28 29 30 |
# File 'lib/contacts/oauth_consumer.rb', line 28 def request_token @request_token end |
Instance Method Details
#authentication_url(target = self.return_url) ⇒ Object
31 32 33 34 |
# File 'lib/contacts/oauth_consumer.rb', line 31 def authentication_url(target = self.return_url) @request_token = consumer.get_request_token({:oauth_callback => target}, @request_token_params) @request_token. end |
#authorize(params) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/contacts/oauth_consumer.rb', line 36 def (params) begin @access_token = @request_token.get_access_token(:oauth_verifier => params['oauth_verifier']) rescue OAuth::Unauthorized => error @error = error. end end |
#initialize_serialized(data) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/contacts/oauth_consumer.rb', line 14 def initialize_serialized(data) value = data['request_token'] and @request_token = deserialize_oauth_token(consumer, value) value = data['access_token'] and @access_token = deserialize_oauth_token(consumer, value) end |
#serializable_data ⇒ Object
21 22 23 24 25 26 |
# File 'lib/contacts/oauth_consumer.rb', line 21 def serializable_data data = {} data['access_token'] = serialize_oauth_token(@access_token) if @access_token data['request_token'] = serialize_oauth_token(@request_token) if @request_token data end |