Skip to content

Commit

Permalink
Merge 9faef42 into 8f3b9e3
Browse files Browse the repository at this point in the history
  • Loading branch information
mynock committed Aug 2, 2015
2 parents 8f3b9e3 + 9faef42 commit 9528fb3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/omniauth/strategies/oauth2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@ def self.inherited(subclass)
attr_accessor :access_token

def client
::OAuth2::Client.new(options.client_id, options.client_secret, deep_symbolize(options.client_options))
::OAuth2::Client.new(client_id, client_secret, deep_symbolize(options.client_options))
end

def client_id
options.client_id.respond_to?(:call) ? options.client_id.call : options.client_id
end

def client_secret
options.client_secret.respond_to?(:call) ? options.client_secret.call : options.client_secret
end

def callback_url
Expand Down
12 changes: 12 additions & 0 deletions spec/omniauth/strategies/oauth2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ def app
instance = subject.new(app, :client_options => {"ssl" => {"ca_path" => "foo"}})
expect(instance.client.options[:connection_opts][:ssl]).to eq(:ca_path => "foo")
end

it "allows client_id to be passed as a lambda function" do
client_id = proc { "abc" }
instance = subject.new(Object, client_id, "def")
expect(instance.client.id).to eq("abc")
end

it "allows client_secret to be passed as a lambda function" do
client_secret = proc { "def" }
instance = subject.new(Object, "abc", client_secret)
expect(instance.client.secret).to eq("def")
end
end

describe "#authorize_params" do
Expand Down

0 comments on commit 9528fb3

Please sign in to comment.