Module: Passport::Oauth::Consumable::ClassMethods

Defined in:
lib/passport/oauth/client/consumable.rb

Instance Method Summary collapse

Instance Method Details

#access_token(token, secret, version = 1.0, options = {}) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/passport/oauth/client/consumable.rb', line 14

def access_token(token, secret, version = 1.0, options = {})
  if version == 1.0
    OAuth::AccessToken.new(consumer, token, secret)
  else
    OAuth2::AccessToken.new(consumer, token)
  end
end

#consumer(options = {}) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/passport/oauth/client/consumable.rb', line 22

def consumer(options = {})
  if version == 1.0
    OAuth::Consumer.new(credentials[:key], credentials[:secret], consumer_settings(options))
  else
    OAuth2::Client.new(credentials[:key], credentials[:secret], consumer_settings(options))
  end
end

#consumer_settings(options = {}) ⇒ Object



10
11
12
# File 'lib/passport/oauth/client/consumable.rb', line 10

def consumer_settings(options = {})
  settings.merge(credentials[:options] || {}).merge(options)
end