Class: OAuth::ConsumerToken
- Defined in:
- lib/oauth/tokens/consumer_token.rb
Overview
Superclass for tokens used by OAuth Clients
Direct Known Subclasses
Instance Attribute Summary collapse
-
#consumer ⇒ Object
Returns the value of attribute consumer.
-
#params ⇒ Object
Returns the value of attribute params.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Attributes inherited from Token
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(consumer, token = "", secret = "") ⇒ ConsumerToken
constructor
A new instance of ConsumerToken.
-
#request(http_method, path, *arguments) ⇒ Object
Make a signed request using given http_method to the path.
-
#sign!(request, options = {}) ⇒ Object
Sign a request generated elsewhere using Net:HTTP::Post.new or friends.
Methods inherited from Token
Methods included from Helper
#escape, #generate_key, #generate_timestamp, #normalize, #normalize_nested_query, #parse_header, #stringify_keys, #unescape
Constructor Details
#initialize(consumer, token = "", secret = "") ⇒ ConsumerToken
Returns a new instance of ConsumerToken.
13 14 15 16 17 |
# File 'lib/oauth/tokens/consumer_token.rb', line 13 def initialize(consumer, token="", secret="") super(token, secret) @consumer = consumer @params = {} end |
Instance Attribute Details
#consumer ⇒ Object
Returns the value of attribute consumer.
4 5 6 |
# File 'lib/oauth/tokens/consumer_token.rb', line 4 def consumer @consumer end |
#params ⇒ Object
Returns the value of attribute params.
4 5 6 |
# File 'lib/oauth/tokens/consumer_token.rb', line 4 def params @params end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/oauth/tokens/consumer_token.rb', line 5 def response @response end |
Class Method Details
.from_hash(consumer, hash) ⇒ Object
7 8 9 10 11 |
# File 'lib/oauth/tokens/consumer_token.rb', line 7 def self.from_hash(consumer, hash) token = self.new(consumer, hash[:oauth_token], hash[:oauth_token_secret]) token.params = hash token end |
Instance Method Details
#request(http_method, path, *arguments) ⇒ Object
Make a signed request using given http_method to the path
@token.request(:get, '/people')
@token.request(:post, '/people', @person.to_xml, { 'Content-Type' => 'application/xml' })
24 25 26 |
# File 'lib/oauth/tokens/consumer_token.rb', line 24 def request(http_method, path, *arguments) @response = consumer.request(http_method, path, self, {}, *arguments) end |
#sign!(request, options = {}) ⇒ Object
Sign a request generated elsewhere using Net:HTTP::Post.new or friends
29 30 31 |
# File 'lib/oauth/tokens/consumer_token.rb', line 29 def sign!(request, = {}) consumer.sign!(request, self, ) end |