mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-22 00:03:38 -04:00
Override API key with client_secret
in OAuth.token
(#890)
This commit is contained in:
parent
e23ae43850
commit
cddd3db2b2
@ -43,6 +43,7 @@ module Stripe
|
|||||||
|
|
||||||
def self.token(params = {}, opts = {})
|
def self.token(params = {}, opts = {})
|
||||||
opts = Util.normalize_opts(opts)
|
opts = Util.normalize_opts(opts)
|
||||||
|
opts[:api_key] = params[:client_secret] if params[:client_secret]
|
||||||
resp, opts = OAuthOperations.request(
|
resp, opts = OAuthOperations.request(
|
||||||
:post, "/oauth/token", params, opts
|
:post, "/oauth/token", params, opts
|
||||||
)
|
)
|
||||||
|
@ -67,6 +67,22 @@ module Stripe
|
|||||||
code: "this_is_an_authorization_code")
|
code: "this_is_an_authorization_code")
|
||||||
assert_equal("sk_access_token", resp.access_token)
|
assert_equal("sk_access_token", resp.access_token)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "override the API key when client_secret is passed" do
|
||||||
|
stub_request(:post, "#{Stripe.connect_base}/oauth/token")
|
||||||
|
.with(body: {
|
||||||
|
"client_secret" => "client_secret_override",
|
||||||
|
"grant_type" => "authorization_code",
|
||||||
|
"code" => "this_is_an_authorization_code",
|
||||||
|
})
|
||||||
|
.with(headers: { "Authorization": "Bearer client_secret_override" })
|
||||||
|
.to_return(body: JSON.generate(access_token: "another_access_token"))
|
||||||
|
|
||||||
|
resp = OAuth.token(client_secret: "client_secret_override",
|
||||||
|
grant_type: "authorization_code",
|
||||||
|
code: "this_is_an_authorization_code")
|
||||||
|
assert_equal("another_access_token", resp.access_token)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context ".deauthorize" do
|
context ".deauthorize" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user