Class: OAuth::Client::Helper

### Home Classes Methods

### In Files

- lib/oauth/client/helper.rb

### Parent

Object

### Methods

- ::new
- #amend_user_agent_header
- #hash_body
- #header
- #nonce
- #oauth_parameters
- #options
- #parameters
- #parameters_with_oauth
- #signature
- #signature_base_string
- #timestamp

### Included Modules

- OAuth::Helper

### Files

- LICENSE
- README.rdoc
- TODO

### Class/Module Index

Quicksearch

- OAuth
- OAuth::AccessToken
- OAuth::CLI
- OAuth::Client
- OAuth::Client::Helper
- OAuth::Consumer
- OAuth::ConsumerToken
- OAuth::Error
- OAuth::Helper
- OAuth::OAuthTestHelper
- OAuth::Problem
- OAuth::RequestProxy
- OAuth::RequestProxy::ActionControllerRequest
- OAuth::RequestProxy::Base
- OAuth::RequestProxy::Curl
- OAuth::RequestProxy::Curl::Easy
- OAuth::RequestProxy::EventMachine
- OAuth::RequestProxy::EventMachine::HttpRequest
- OAuth::RequestProxy::JabberRequest
- OAuth::RequestProxy::MockRequest
- OAuth::RequestProxy::Net
- OAuth::RequestProxy::Net::HTTP
- OAuth::RequestProxy::Net::HTTP::HTTPRequest
- OAuth::RequestProxy::RackRequest
- OAuth::RequestProxy::Typhoeus
- OAuth::RequestProxy::Typhoeus::Request
- OAuth::RequestProxy::UnknownRequestType
- OAuth::RequestToken
- OAuth::Server
- OAuth::ServerToken
- OAuth::Signature
- OAuth::Signature::Base
- OAuth::Signature::HMAC
- OAuth::Signature::HMAC::Base
- OAuth::Signature::HMAC::MD5
- OAuth::Signature::HMAC::RMD160
- OAuth::Signature::HMAC::SHA1
- OAuth::Signature::HMAC::SHA2
- OAuth::Signature::MD5
- OAuth::Signature::PLAINTEXT
- OAuth::Signature::RSA
- OAuth::Signature::RSA::SHA1
- OAuth::Signature::SHA1
- OAuth::Signature::UnknownSignatureMethod
- OAuth::Token
- OAuth::Unauthorized
- ActionController
- ActionController::Base
- ActionController::TestRequest
- Digest
- Digest::HMAC
- EventMachine
- EventMachine::HttpClient
- Net
- Net::HTTPGenericRequest
- Object
- String

No matching classes.

# OAuth::Client::Helper

### Public Class Methods

new(request, options = {}) click to toggle source

    # File lib/oauth/client/helper.rb, line 11
    def initialize(request, options = {})
      @request = request
      @options = options
      @options[:signature_method] ||= 'HMAC-SHA1'
    end

### Public Instance Methods

amend_user_agent_header(headers) click to toggle source

    # File lib/oauth/client/helper.rb, line 63
    def amend_user_agent_header(headers)
      @oauth_ua_string ||= "OAuth gem v#{OAuth::VERSION}"
      # Net::HTTP in 1.9 appends Ruby
      if headers['User-Agent'] && headers['User-Agent'] != 'Ruby'
        headers['User-Agent'] += " (#{@oauth_ua_string})"
      else
        headers['User-Agent'] = @oauth_ua_string
      end
    end

hash_body() click to toggle source

    # File lib/oauth/client/helper.rb, line 59
    def hash_body
      @options[:body_hash] = OAuth::Signature.body_hash(@request, :parameters => oauth_parameters)
    end

header() click to toggle source

    # File lib/oauth/client/helper.rb, line 73
    def header
      parameters = oauth_parameters
      parameters.merge!('oauth_signature' => signature(options.merge(:parameters => parameters)))

      header_params_str = parameters.sort.map { |k,v| "#{k}=\"#{escape(v)}\"" }.join(', ')

      realm = "realm=\"#{options[:realm]}\", " if options[:realm]
      "OAuth #{realm}#{header_params_str}"
    end

nonce() click to toggle source

    # File lib/oauth/client/helper.rb, line 21
    def nonce
      options[:nonce] ||= generate_key
    end

oauth_parameters() click to toggle source

    # File lib/oauth/client/helper.rb, line 29
    def oauth_parameters
      {
        'oauth_body_hash'        => options[:body_hash],
        'oauth_callback'         => options[:oauth_callback],
        'oauth_consumer_key'     => options[:consumer].key,
        'oauth_token'            => options[:token] ? options[:token].token : '',
        'oauth_signature_method' => options[:signature_method],
        'oauth_timestamp'        => timestamp,
        'oauth_nonce'            => nonce,
        'oauth_verifier'         => options[:oauth_verifier],
        'oauth_version'          => (options[:oauth_version] || '1.0'),
        'oauth_session_handle'   => options[:oauth_session_handle]
      }.reject { |k,v| v.to_s == "" }
    end

options() click to toggle source

    # File lib/oauth/client/helper.rb, line 17
    def options
      @options
    end

parameters() click to toggle source

    # File lib/oauth/client/helper.rb, line 83
    def parameters
      OAuth::RequestProxy.proxy(@request).parameters
    end

parameters_with_oauth() click to toggle source

    # File lib/oauth/client/helper.rb, line 87
    def parameters_with_oauth
      oauth_parameters.merge(parameters)
    end

signature(extra_options = {}) click to toggle source

    # File lib/oauth/client/helper.rb, line 44
    def signature(extra_options = {})
      OAuth::Signature.sign(@request, { :uri      => options[:request_uri],
                                        :consumer => options[:consumer],
                                        :token    => options[:token],
                                        :unsigned_parameters => options[:unsigned_parameters]
      }.merge(extra_options) )
    end

signature_base_string(extra_options = {}) click to toggle source

    # File lib/oauth/client/helper.rb, line 52
    def signature_base_string(extra_options = {})
      OAuth::Signature.signature_base_string(@request, { :uri        => options[:request_uri],
                                                         :consumer   => options[:consumer],
                                                         :token      => options[:token],
                                                         :parameters => oauth_parameters}.merge(extra_options) )
    end

timestamp() click to toggle source

    # File lib/oauth/client/helper.rb, line 25
    def timestamp
      options[:timestamp] ||= generate_timestamp
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.