-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Migrating OAuth notebook #990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Aarchi-07
commented
Oct 11, 2025
- Updated SDK imports
- lint checked
- nbfmt
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Summary of ChangesHello @Aarchi-07, 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 focuses on updating the Highlights
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly migrates the OAuth notebook to the new google-genai
SDK. However, it introduces a critical error by adding API key authentication to a notebook that is specifically designed to demonstrate OAuth authentication. This defeats the purpose of the quickstart. Additionally, the notebook's execution_count
fields have been populated, which indicates the formatting script was not run before submission, a violation of the repository's style guide.
"from google import genai\n", | ||
"from google.colab import userdata\n", | ||
"\n", | ||
"print('Available base models:', [m.name for m in genai.list_models()])" | ||
"GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY')\n", | ||
"client = genai.Client(api_key=GOOGLE_API_KEY)\n", | ||
"\n", | ||
"print('Available base models:', [m.name for m in client.models.list()])" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is incorrect for this specific notebook. The purpose of the 'Authentication with OAuth' quickstart is to demonstrate authentication using Application Default Credentials (ADC), not an API key. The preceding cells guide the user through setting up OAuth, and the SDK should automatically use those credentials if the client is initialized without arguments. Explicitly using an API key here defeats the purpose of the example and contradicts the notebook's own instructions in the preceding markdown cell.1
from google import genai
# The client will automatically use the application default credentials
# you set up earlier in the notebook.
client = genai.Client()
print('Available base models:', [m.name for m in client.models.list()])
Style Guide References
Footnotes
-
The style guide mandates using the new
google-genai
SDK. The logic of this notebook, as described in its own text (lines 251-254, 283), is to rely on Application Default Credentials, not an API key. This change breaks that fundamental logic. ↩
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"execution_count": 2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The execution_count
for this cell is set to 2
instead of null
. According to the style guide, this indicates that the formatting script has not been run after the cell was executed. Please run the formatter to clear execution counts and outputs before submitting.1
Style Guide References
Footnotes
-
The style guide states that if
execution_count
is notnull
, it usually means the formatting script needs to be run. ↩
], | ||
"source": [ | ||
"%pip install -U -q \"google-generativeai>=0.7.2\"" | ||
"%pip install -U -q \"google-genai\"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SDK package name has been correctly updated to google-genai
. However, the style guide recommends specifying a minimum version to ensure notebook compatibility with required features.1 Please add a version constraint.
%pip install -U -q 'google-genai>=1.0.0'
Style Guide References
Footnotes
-
The style guide specifies that the SDK should be installed with a minimum version, such as
>=1.0.0
, to guarantee feature availability. ↩
I was unable to migrate the "Authenticate with the Python SDK by service account key" section and would appreciate any guidance. |