Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle error responses from the token requests #319

Merged
merged 1 commit into from
Oct 27, 2024

Conversation

rtimush
Copy link
Contributor

@rtimush rtimush commented Oct 24, 2024

Currently, the token source tries to parse a response into a token even if the response was not successful.
This makes it difficult to debug what was the actual error cause, as the token source fails with an error like this:

http error: error decoding response body

Caused by:
0: error decoding response body
1: missing field `access_token` at line 1 column 70

while the actual response can for example be a HTTP 400 Bad Request with a body like this:

{"error":"invalid_grant","error_description":"Invalid JWT Signature."}

The full list of possible error codes can be found here: https://developers.google.com/identity/protocols/oauth2/service-account#error-codes

This PR adds a check for the response status, and tries to parse the error response.

@yoshidan yoshidan added the safe to test safe to test label Oct 27, 2024
@yoshidan yoshidan merged commit 5d28101 into yoshidan:main Oct 27, 2024
9 checks passed
@yoshidan
Copy link
Owner

Thank you for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test safe to test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants