Class Net::HTTPRequest
In: lib/oauth/client/net_http.rb
Parent: Object

Methods

Included Modules

OAuth::Helper

Attributes

oauth_helper  [R] 

Public Instance methods

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

[Source]

# File lib/oauth/client/net_http.rb, line 24
  def oauth!(http, consumer = nil, token = nil, options = {})
    options = { :request_uri      => oauth_full_request_uri(http),
                :consumer         => consumer,
                :token            => token,
                :scheme           => 'header',
                :signature_method => nil,
                :nonce            => nil,
                :timestamp        => nil }.merge(options)

    @oauth_helper = OAuth::Client::Helper.new(self, options)
    @oauth_helper.amend_user_agent_header(self)
    self.send("set_oauth_#{options[:scheme]}")
  end

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 9.1.1

[Source]

# File lib/oauth/client/net_http.rb, line 51
  def signature_base_string(http, consumer = nil, token = nil, options = {})
    options = { :request_uri      => oauth_full_request_uri(http),
                :consumer         => consumer,
                :token            => token,
                :scheme           => 'header',
                :signature_method => nil,
                :nonce            => nil,
                :timestamp        => nil }.merge(options)

    OAuth::Client::Helper.new(self, options).signature_base_string
  end

[Validate]