Class: Net::HTTPRequest
- Inherits:
-
Object
- Object
- Net::HTTPRequest
- 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, #parse_header, #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.
This method also modifies the User-Agent
header to add the OAuth gem version.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/oauth/client/net_http.rb', line 18 def oauth!(http, consumer = nil, token = nil, = {}) = { :request_uri => oauth_full_request_uri(http), :consumer => consumer, :token => token, :scheme => 'header', :signature_method => nil, :nonce => nil, :timestamp => nil }.merge() @oauth_helper = OAuth::Client::Helper.new(self, ) @oauth_helper.amend_user_agent_header(self) 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.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/oauth/client/net_http.rb', line 39 def signature_base_string(http, consumer = nil, token = nil, = {}) = { :request_uri => oauth_full_request_uri(http), :consumer => consumer, :token => token, :scheme => 'header', :signature_method => nil, :nonce => nil, :timestamp => nil }.merge() OAuth::Client::Helper.new(self, ).signature_base_string end |