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, 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.
15 16 17 18 19 |
# File 'lib/oauth/tokens/consumer_token.rb', line 15 def initialize(consumer, token = "", secret = "") super(token, secret) @consumer = consumer @params = {} end |
Instance Attribute Details
#consumer ⇒ Object
Returns the value of attribute consumer.
6 7 8 |
# File 'lib/oauth/tokens/consumer_token.rb', line 6 def consumer @consumer end |
#params ⇒ Object
Returns the value of attribute params.
6 7 8 |
# File 'lib/oauth/tokens/consumer_token.rb', line 6 def params @params end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
7 8 9 |
# File 'lib/oauth/tokens/consumer_token.rb', line 7 def response @response end |
Class Method Details
.from_hash(consumer, hash) ⇒ Object
9 10 11 12 13 |
# File 'lib/oauth/tokens/consumer_token.rb', line 9 def self.from_hash(consumer, hash) token = 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' })
26 27 28 |
# File 'lib/oauth/tokens/consumer_token.rb', line 26 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
31 32 33 |
# File 'lib/oauth/tokens/consumer_token.rb', line 31 def sign!(request, = {}) consumer.sign!(request, self, ) end |