Class | OAuth::Consumer |
In: |
lib/oauth/consumer.rb
|
Parent: | Object |
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) |
http | [W] | |
key | [RW] | |
options | [RW] | |
secret | [RW] | |
site | [W] |
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')
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
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' })
Creates a request and parses the result as url_encoded. This is used internally for the RequestToken and AccessToken requests.
create the http request object for a given http_method and path
Unset cached http instance because it cannot be marshalled when it has already been used and use_ssl is set to true