mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-05-24 00:01:51 -04:00
Merge pull request #562 from ymendel/handle_invalid_client_oauth_error
handle invalid-client oauth error
This commit is contained in:
commit
713d7f9fa8
@ -114,6 +114,12 @@ module Stripe
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# InvalidClientError is raised when the client doesn't belong to you, or
|
||||||
|
# the API key mode (live or test) doesn't match the client mode. Or the
|
||||||
|
# stripe_user_id doesn't exist or isn't connected to your application.
|
||||||
|
class InvalidClientError < OAuthError
|
||||||
|
end
|
||||||
|
|
||||||
# InvalidGrantError is raised when a specified code doesn't exist, is
|
# InvalidGrantError is raised when a specified code doesn't exist, is
|
||||||
# expired, has been used, or doesn't belong to you; a refresh token doesn't
|
# expired, has been used, or doesn't belong to you; a refresh token doesn't
|
||||||
# exist, or doesn't belong to you; or if an API key's mode (live or test)
|
# exist, or doesn't belong to you; or if an API key's mode (live or test)
|
||||||
|
@ -312,6 +312,7 @@ module Stripe
|
|||||||
}]
|
}]
|
||||||
|
|
||||||
case error_code
|
case error_code
|
||||||
|
when 'invalid_client' then OAuth::InvalidClientError.new(*args)
|
||||||
when 'invalid_grant' then OAuth::InvalidGrantError.new(*args)
|
when 'invalid_grant' then OAuth::InvalidGrantError.new(*args)
|
||||||
when 'invalid_request' then OAuth::InvalidRequestError.new(*args)
|
when 'invalid_request' then OAuth::InvalidRequestError.new(*args)
|
||||||
when 'invalid_scope' then OAuth::InvalidScopeError.new(*args)
|
when 'invalid_scope' then OAuth::InvalidScopeError.new(*args)
|
||||||
|
@ -368,6 +368,24 @@ module Stripe
|
|||||||
assert_equal('invalid_grant', e.code)
|
assert_equal('invalid_grant', e.code)
|
||||||
assert_equal('This authorization code has already been used. All tokens issued with this code have been revoked.', e.message)
|
assert_equal('This authorization code has already been used. All tokens issued with this code have been revoked.', e.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "raise OAuth::InvalidClientError when error is a string with value 'invalid_client'" do
|
||||||
|
stub_request(:post, "#{Stripe.connect_base}/oauth/deauthorize").
|
||||||
|
to_return(body: JSON.generate({
|
||||||
|
error: "invalid_client",
|
||||||
|
error_description: "This application is not connected to stripe account acct_19tLK7DSlTMT26Mk, or that account does not exist.",
|
||||||
|
}), status: 401)
|
||||||
|
|
||||||
|
client = StripeClient.new
|
||||||
|
opts = {api_base: Stripe.connect_base}
|
||||||
|
e = assert_raises Stripe::OAuth::InvalidClientError do
|
||||||
|
client.execute_request(:post, '/oauth/deauthorize', opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal(401, e.http_status)
|
||||||
|
assert_equal('invalid_client', e.code)
|
||||||
|
assert_equal('This application is not connected to stripe account acct_19tLK7DSlTMT26Mk, or that account does not exist.', e.message)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "idempotency keys" do
|
context "idempotency keys" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user