Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request implements a mechanism to refresh URL-derived self-signed JWTs upon receiving a 401 Unauthorized response across various transport layers, including aiohttp, requests, and urllib3. The feedback highlights critical NameError bugs in requests.py and urllib3.py due to missing imports of service_account. To fix these errors and prevent circular dependencies, it is highly recommended to use duck typing with getattr to check for the _refresh_self_signed_jwt_for_url method across all transport adapters instead of using explicit isinstance checks.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
force_refresh=Falseto_get_self_signed_jwt_for_audience()and add_refresh_self_signed_jwt_for_url(request, url)onservice_account.Credentialsto force-refresh the cached per-audience JWT for a given request URL.401retry handling ingoogle/auth/transport/requests.py(AuthorizedSession),google/auth/transport/urllib3.py(AuthorizedHttp),google/auth/transport/_aiohttp_requests.py(AuthorizedSession), andgoogle/auth/aio/transport/sessions.py(_SyncCredentialsAdapter/AsyncAuthorizedSession) to call_refresh_self_signed_jwt_for_url()when applicable instead ofcredentials.refresh(), ensuring retries mint a fresh per-audience JWT without raisingRefreshErroror reusing a cached token.Stacked on #19280.