Class OAuth::Consumer
In: lib/oauth/consumer.rb
Parent: Object

Methods

Constants

CA_FILES = %w(/etc/ssl/certs/ca-certificates.crt /usr/share/curl/curl-ca-bundle.crt)   determine the certificate authority path to verify SSL certs
CA_FILE = ca_file
CA_FILE = nil unless defined?(CA_FILE)

Attributes

http  [W] 
key  [RW] 
options  [RW] 
secret  [RW] 
site  [W] 

Public Class methods

Create a new consumer instance by passing it a configuration hash:

  @consumer = OAuth::Consumer.new(key, secret, {
    :site               => "http://term.ie",
    :scheme             => :header,
    :http_method        => :post,
    :request_token_path => "/oauth/example/request_token.php",
    :access_token_path  => "/oauth/example/access_token.php",
    :authorize_path     => "/oauth/example/authorize.php"
   })

Start the process by requesting a token

  @request_token = @consumer.get_request_token
  session[:request_token] = @request_token
  redirect_to @request_token.authorize_url

When user returns create an access_token

  @access_token = @request_token.get_access_token
  @photos=@access_token.get('/photos.xml')

Public Instance methods

Creates and signs an http request. It‘s recommended to use the Token classes to set this up correctly

Makes a request to the service for a new OAuth::RequestToken

 @request_token = @consumer.get_request_token

To include OAuth parameters:

 @request_token = @consumer.get_request_token      #    :oauth_callback => "http://example.com/cb"

To include application-specific parameters:

 @request_token = @consumer.get_request_token({}, :foo => "bar")

TODO oauth_callback should be a mandatory parameter

The HTTP object for the site. The HTTP Object is what you get when you do Net::HTTP.new

The default http method

Creates, signs and performs an http request. It‘s recommended to use the OAuth::Token classes to set this up correctly. request_options take precedence over consumer-wide options when signing

  a request.

arguments are POST and PUT bodies (a Hash, string-encoded parameters, or

  absent), followed by additional HTTP headers.

  @consumer.request(:get,  '/people', @token, { :scheme => :query_string })
  @consumer.request(:post, '/people', @token, {}, @person.to_xml, { 'Content-Type' => 'application/xml' })

TODO this is ugly, rewrite

Sign the Request object. Use this if you have an externally generated http request object you want to sign.

Creates a request and parses the result as url_encoded. This is used internally for the RequestToken and AccessToken requests.

Contains the root URI for this site

Protected Instance methods

Instantiates the http object

[Validate]