Class: ApipieBindings::Authenticators::Oauth

Inherits:
Base
  • Object
show all
Defined in:
lib/apipie_bindings/authenticators/oauth.rb

Instance Attribute Summary

Attributes inherited from Base

#auth_cookie

Instance Method Summary collapse

Methods inherited from Base

#error, #name, #response

Constructor Details

#initialize(consumer_key, consumer_secret, options = {}) ⇒ Oauth

Returns a new instance of Oauth.



6
7
8
9
10
# File 'lib/apipie_bindings/authenticators/oauth.rb', line 6

def initialize(consumer_key, consumer_secret, options = {})
  @consumer_key = consumer_key
  @consumer_secret = consumer_secret
  @options = options
end

Instance Method Details

#authenticate(request, args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/apipie_bindings/authenticators/oauth.rb', line 12

def authenticate(request, args)
  uri = URI.parse args[:url]
  default_options = {
    :site => "#{uri.scheme}://#{uri.host}:#{uri.port.to_s}",
    :request_token_path => "",
    :authorize_path => "",
    :access_token_path  => ""
  }
  options = default_options.merge(@options)
  consumer = OAuth::Consumer.new(@consumer_key, @consumer_secret, options)

  consumer.sign!(request)
end