Repository navigation
fix(auth): preserve existing refresh_token when OAuth2 refresh omits it - #8481
Open
1828703450qqcom-ux wants to merge 1 commit into
Open
1828703450qqcom-ux wants to merge 1 commit into
1828703450qqcom-ux wants to merge 1 commit into
Conversation
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
Preserves the existing
refresh_tokenduring OAuth2 token refresh when the authorization server omitsrefresh_tokenfrom its response (per RFC 6749 §6, e.g., Google'soauth2.googleapis.com/tokennon-rotating refresh grants):src/google/adk/auth/refresher/oauth2_credential_refresher.py:auth_credential.oauth2.refresh_tokenbefore callingclient.refresh_token(...)and restores it ifupdate_credential_with_tokens(...)clearedrefresh_tokenbecause the response omitted it.refresh_tokenwithNone(andCredentialManagerpersisted that corrupted state), causing all subsequent token expirations to abort refresh with"OAuth2 token expired and has no refresh token; cannot refresh".src/google/adk/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.py:OAuth2CredentialExchanger._refresh_token().tests/unittests/auth/refresher/test_oauth2_credential_refresher.py: verifiesrefresh_tokensurvives consecutive refreshes when omitted by the token endpoint.tests/unittests/tools/openapi_tool/auth/credential_exchangers/test_oauth2_exchanger.py: verifiesOAuth2CredentialExchanger.exchange_credential()preserves the existingrefresh_tokenwhen omitted from a refresh grant response.Verification
.venv\Scripts\python.exe -m pytest tests/unittests/auth/refresher/test_oauth2_credential_refresher.py tests/unittests/tools/openapi_tool/auth/credential_exchangers/test_oauth2_exchanger.py tests/unittests/auth/test_credential_manager.py -qpyink --check,isort --check,ruff check,scripts/compliance_checks.py