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

Raise HTTP error if encountered #1167

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

joshtemple
Copy link

Currently, if the user is not authorized to make a request, there is no token in the response so the user receives a KeyError, which is less informative than the HTTPError returned from the API.

Raising the HTTP error solves this.

@@ -433,6 +433,7 @@ def refresh(self, request):
headers=headers,
data=json.dumps(body).encode("utf-8"),
)
response.raise_for_status()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you write a test for this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@clundin25, I've attempted to write a test. Let me know if you'd like me to approach it differently.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refresh method normally throws RefreshError (https://github.com/googleapis/google-auth-library-python/blob/main/google/auth/exceptions.py#L35), could you maybe check the status code and raise a RefreshError instead?

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

Successfully merging this pull request may close these issues.

3 participants