feat(apigee): add userinfo.email scope for tokeninfo user identification#4722
feat(apigee): add userinfo.email scope for tokeninfo user identification#4722polar3130 wants to merge 1 commit intogoogle:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Response from ADK Triaging Agent Hello @polar3130, thank you for your contribution! It looks like the Contributor License Agreement (CLA) check has failed. Before we can merge this PR, you'll need to sign the CLA. You can find more information in the "checks" section at the bottom of the pull request. Thanks! |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the ApigeeLlm client's authentication mechanism by explicitly requesting the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request successfully implements the requested feature to add the userinfo.email scope for tokeninfo user identification in ApigeeLlm.api_client. The changes are well-contained within the ApigeeLlm class and do not impact other parts of the codebase. A new unit test has been added to verify the correct behavior, which is a good practice.
| assert 'https://www.googleapis.com/auth/userinfo.email' in _APIGEE_SCOPES | ||
| assert 'https://www.googleapis.com/auth/cloud-platform' in _APIGEE_SCOPES |
There was a problem hiding this comment.
These assertions are redundant. The test already verifies that mock_auth_default is called with _APIGEE_SCOPES on line 664. If the _APIGEE_SCOPES constant itself is incorrectly defined in apigee_llm.py, that would be a bug in the constant's definition, not in how it's used by api_client. Removing these lines will make the test more concise and focused on the behavior of api_client.
ApigeeLlm now explicitly requests the userinfo.email OAuth scope alongside cloud-platform when creating credentials. This enables Apigee Gateway to identify callers via Google's tokeninfo API when using Service Account key authentication. Fixes google#4721
c412162 to
59c654f
Compare
Summary
ApigeeLlm.api_clientnow explicitly callsgoogle.auth.default()with bothcloud-platformanduserinfo.emailscopes, and passes the credentials togenai.ClientApigeeLlmonly — no impact on baseGeminiclass orgenaiSDKFixes #4721
Test plan
test_api_client_requests_userinfo_email_scopeverifyinggoogle.auth.defaultis called with the correct scopes and credentials are passed togenai.Clienttest_apigee_llm.pypass🤖 Generated with Claude Code