lib/omniauth/strategies/oauth2.rb in oa-oauth-0.1.6 vs lib/omniauth/strategies/oauth2.rb in oa-oauth-0.2.0.beta1
- old
+ new
@@ -14,11 +14,11 @@
include OmniAuth::Strategy
# The options passed in to the strategy.
attr_accessor :options
# The `OAuth2::Client` for this strategy.
- attr_accessor :client
+ attr_accessor :client_id, :client_secret, :client_options
# An error that is indicated in the OAuth 2.0 callback.
# This could be a `redirect_uri_mismatch` or other
class CallbackError < StandardError
attr_accessor :error, :error_reason, :error_uri
@@ -35,13 +35,18 @@
# @param [Rack Application] app standard middleware application argument
# @param [String] name the name for this provider to be used in its URL, e.g. `/auth/name`
# @param [String] client_id the client/application ID of this provider
# @param [String] client_secret the client/application secret of this provider
# @param [Hash] options that will be passed through to the OAuth2::Client (see [oauth2 docs](http://rubydoc.info/gems/oauth2))
- def initialize(app, name, client_id, client_secret, options = {})
- super(app, name)
- self.options = options
- self.client = ::OAuth2::Client.new(client_id, client_secret, options)
+ def initialize(app, name, client_id = nil, client_secret = nil, client_options = {}, options = {}, &block)
+ self.client_id = client_id
+ self.client_secret = client_secret
+ self.client_options = client_options
+ super
+ end
+
+ def client
+ ::OAuth2::Client.new(client_id, client_secret, client_options.merge(options[:client_options] || {}))
end
protected
def request_phase