Repository navigation
Reuse a valid Google access token in GoogleAuthManager - #4376
Open
chenjian2664 wants to merge 1 commit into
Open
chenjian2664 wants to merge 1 commit into
chenjian2664 wants to merge 1 commit into
Conversation
GoogleAuthManager refreshed its credentials before every REST catalog request, so each call made an extra round trip to Google's token endpoint. Refresh only when the credentials are not valid, which is what google-auth does itself before a request.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The token-reuse change has no active review issues.
No open issues 🎉
What changed in this PR
Updates GoogleAuthManager to reuse valid access tokens, avoiding an unnecessary Google token-endpoint request before each REST catalog call.
Changes:
- Refresh credentials only when they are invalid.
- Add tests for token reuse and refresh near expiry.
- Mark existing credential mocks as invalid to preserve refresh assertions.
| File | Description |
|---|---|
tests/catalog/test_rest.py |
Updates the credential mock to exercise token refresh. |
tests/catalog/test_rest_auth.py |
Adds token-reuse and near-expiry refresh tests; updates existing mocks. |
pyiceberg/catalog/rest/auth.py |
Checks credential validity before refreshing the access token. |
Review effort: Balanced
rambleraptor
approved these changes
Nov 14, 2026
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.
Rationale for this change
GoogleAuthManagerrefreshed its credentials before every REST catalog request, so each catalog call also made a round trip to Google's token endpoint. This was raised in review on #2072. It now refreshes only when the credentials are not valid, which is what google-auth does itself before a request.Are these changes tested?
Are there any user-facing changes?