Class: OAuth::Client::Helper
- Inherits:
-
Object
- Object
- OAuth::Client::Helper
- Includes:
- Helper
- Defined in:
- lib/oauth/client/helper.rb
Instance Method Summary collapse
- #generate_timestamp ⇒ Object
- #header ⇒ Object
-
#initialize(request, options = {}) ⇒ Helper
constructor
A new instance of Helper.
- #nonce ⇒ Object
- #oauth_parameters ⇒ Object
- #options ⇒ Object
- #parameters ⇒ Object
- #parameters_with_oauth ⇒ Object
- #signature(extra_options = {}) ⇒ Object
- #signature_base_string(extra_options = {}) ⇒ Object
- #timestamp ⇒ Object
Methods included from Helper
Constructor Details
#initialize(request, options = {}) ⇒ Helper
Returns a new instance of Helper.
11 12 13 14 15 |
# File 'lib/oauth/client/helper.rb', line 11 def initialize(request, = {}) @request = request = [:signature_method] ||= 'HMAC-SHA1' end |
Instance Method Details
#generate_timestamp ⇒ Object
29 30 31 |
# File 'lib/oauth/client/helper.rb', line 29 def Time.now.to_i.to_s end |
#header ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/oauth/client/helper.rb', line 57 def header parameters = oauth_parameters parameters.merge!( { 'oauth_signature' => signature( .merge({ :parameters => parameters }) ) } ) header_params_str = parameters.map { |k,v| "#{k}=\"#{escape(v)}\"" }.join(', ') return "OAuth realm=\"#{options[:realm]||''}\", #{header_params_str}" end |
#nonce ⇒ Object
21 22 23 |
# File 'lib/oauth/client/helper.rb', line 21 def nonce [:nonce] ||= generate_key end |
#oauth_parameters ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/oauth/client/helper.rb', line 33 def oauth_parameters { 'oauth_consumer_key' => [:consumer].key, 'oauth_token' => [:token] ? [:token].token : '', 'oauth_signature_method' => [:signature_method], 'oauth_timestamp' => , 'oauth_nonce' => nonce, 'oauth_version' => '1.0' } end |
#options ⇒ Object
17 18 19 |
# File 'lib/oauth/client/helper.rb', line 17 def end |
#parameters ⇒ Object
66 67 68 |
# File 'lib/oauth/client/helper.rb', line 66 def parameters OAuth::RequestProxy.proxy(@request).parameters end |
#parameters_with_oauth ⇒ Object
70 71 72 |
# File 'lib/oauth/client/helper.rb', line 70 def parameters_with_oauth oauth_parameters.merge( parameters ) end |
#signature(extra_options = {}) ⇒ Object
44 45 46 47 48 |
# File 'lib/oauth/client/helper.rb', line 44 def signature( = {}) OAuth::Signature.sign(@request, { :uri => [:request_uri], :consumer => [:consumer], :token => [:token] }.merge() ) end |
#signature_base_string(extra_options = {}) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/oauth/client/helper.rb', line 50 def signature_base_string( = {}) OAuth::Signature.signature_base_string(@request, { :uri => [:request_uri], :consumer => [:consumer], :token => [:token], :parameters => oauth_parameters}.merge() ) end |
#timestamp ⇒ Object
25 26 27 |
# File 'lib/oauth/client/helper.rb', line 25 def [:timestamp] ||= end |