fix(auth): Support fallback OAuth token and prefixless credential lookups in session state#5899
Open
tonycoco wants to merge 1 commit into
Open
fix(auth): Support fallback OAuth token and prefixless credential lookups in session state#5899tonycoco wants to merge 1 commit into
tonycoco wants to merge 1 commit into
Conversation
Collaborator
|
Response from ADK Triaging Agent Hello @tonycoco, thank you for creating this PR! This PR is a bug fix for #4712, but we noticed that it is missing some information required by our contribution guidelines:
Providing this information will help reviewers process and review your PR much more efficiently. Thank you for your contribution! |
9535ce7 to
2642ad0
Compare
…kups in session state Session state might store authentication responses as raw string tokens instead of AuthCredential objects, or under custom credential keys without the standard "temp:" prefix. Add robust fallback handling to resolve raw token strings, check for prefixless keys, and scan state values for any Google OAuth access tokens starting with "ya29."
2642ad0 to
b62b7b3
Compare
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.
Fixes #4712
Session state might store authentication responses as raw string tokens instead of AuthCredential objects, or under custom credential keys without the standard "temp:" prefix.
Add robust fallback handling to resolve raw token strings, check for prefixless keys, and scan state values for any Google OAuth access tokens starting with "ya29."
The patch updates the
get_auth_responsemethod ingoogle/adk/auth/auth_handler.pyto do the following:Check
temp:<key>prefix: This maintains the standard OAuth redirection flow.Check
<key>directly: This allows resolving credentials where the application or environment provides them under the exact configuration key without prefixes.Scan session state for OAuth tokens: This dynamically scans the state dictionary for active Google Cloud access tokens starting with the standard
"ya29."prefix. This is common in hosted Google Cloud environments such as Vertex AI Reasoning Engine.Unit Tests:
Checklist