Module: Warden::OAuth::ConfigExtension

Defined in:
lib/warden_oauth/config_extension.rb

Overview

Holds all the extensions made to Warden::Config in order to create OAuth consumers.

Instance Method Summary collapse

Instance Method Details

#oauth(service, &block) ⇒ Object

Helps to setup a new OAuth client authentication, to get started you need to define a service name, and then on the block assign the different values required in order to boot the OAuth process.

Examples:

use Warden::Manager do |config|
  config.oauth(:twitter) do
    consumer_key "<YOUR CONSUMER KEY>"
    consumer_secret "<YOUR CONSUMER SECRET>"
    options :site => 'http://twitter.com'
  end
end

Parameters:

  • service (Symbol)

    An identifier of the OAuth service



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/warden_oauth/config_extension.rb', line 25

def oauth(service, &block)
  config = Warden::OAuth::Config.new
  if block_given?
    if block.arity == 1 
      yield config 
    else
      config.instance_eval(&block)
    end
  end
  config.check_requirements
  config.provider_name = service
  Warden::OAuth::Strategy.build(service, config)
end