Class: Net::HTTPGenericRequest
- Includes:
- OAuth::Helper
- Defined in:
- lib/oauth/client/net_http.rb
Instance Attribute Summary collapse
-
#oauth_helper ⇒ Object
readonly
Returns the value of attribute oauth_helper.
Instance Method Summary collapse
-
#oauth!(http, consumer = nil, token = nil, options = {}) ⇒ Object
Add the OAuth information to an HTTP request.
-
#signature_base_string(http, consumer = nil, token = nil, options = {}) ⇒ Object
Create a string suitable for signing for an HTTP request.
Methods included from OAuth::Helper
#escape, #generate_key, #generate_timestamp, #normalize, #normalize_nested_query, #parse_header, #stringify_keys, #unescape
Instance Attribute Details
#oauth_helper ⇒ Object (readonly)
Returns the value of attribute oauth_helper.
8 9 10 |
# File 'lib/oauth/client/net_http.rb', line 8 def oauth_helper @oauth_helper end |
Instance Method Details
#oauth!(http, consumer = nil, token = nil, options = {}) ⇒ Object
Add the OAuth information to an HTTP request. Depending on the options[:scheme]
setting this may add a header, additional query string parameters, or additional POST body parameters. The default scheme is header
, in which the OAuth parameters as put into the Authorization
header.
-
http - Configured Net::HTTP instance
-
consumer - OAuth::Consumer instance
-
token - OAuth::Token instance
-
options - Request-specific options (e.g.
request_uri
,consumer
,token
,scheme
,signature_method
,nonce
,timestamp
)
This method also modifies the User-Agent
header to add the OAuth gem version.
See Also: OAuth core spec version 1.0, section 5.4.1,
{OAuth Request Body Hash 1.0 Draft 4}[http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/drafts/4/spec.html,
http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html#when_to_include]
26 27 28 29 30 31 32 |
# File 'lib/oauth/client/net_http.rb', line 26 def oauth!(http, consumer = nil, token = nil, = {}) = (http, consumer, token, ) @oauth_helper = OAuth::Client::Helper.new(self, ) @oauth_helper.amend_user_agent_header(self) @oauth_helper.hash_body if oauth_body_hash_required? self.send("set_oauth_#{[:scheme]}") end |
#signature_base_string(http, consumer = nil, token = nil, options = {}) ⇒ Object
Create a string suitable for signing for an HTTP request. This process involves parameter normalization as specified in the OAuth specification. The exact normalization also depends on the options[:scheme]
being used so this must match what will be used for the request itself. The default scheme is header
, in which the OAuth parameters as put into the Authorization
header.
-
http - Configured Net::HTTP instance
-
consumer - OAuth::Consumer instance
-
token - OAuth::Token instance
-
options - Request-specific options (e.g.
request_uri
,consumer
,token
,scheme
,signature_method
,nonce
,timestamp
)
See Also: OAuth core spec version 1.0, section 5.4.1,
{OAuth Request Body Hash 1.0 Draft 4}[http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/drafts/4/spec.html,
http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html#when_to_include]
49 50 51 52 53 54 |
# File 'lib/oauth/client/net_http.rb', line 49 def signature_base_string(http, consumer = nil, token = nil, = {}) = (http, consumer, token, ) @oauth_helper = OAuth::Client::Helper.new(self, ) @oauth_helper.hash_body if oauth_body_hash_required? @oauth_helper.signature_base_string end |