Skip to content

Conversation

Aarchi-07
Copy link

  • Updated SDK imports
  • lint checked
  • nbfmt

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions github-actions bot added status:awaiting review PR awaiting review from a maintainer component:quickstarts Issues/PR referencing quickstarts folder labels Oct 11, 2025
Copy link
Contributor

Summary of Changes

Hello @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 Authentication_with_OAuth.ipynb quickstart notebook to align with current best practices and SDK versions. The primary goal is to transition the notebook's code to use the google-genai library, replacing its predecessor. This involves modifying import statements, enhancing API key security through google.colab.userdata, and ensuring the notebook's output reflects the latest execution results and formatting standards.

Highlights

  • SDK Migration: The notebook has been migrated from using the older google-generativeai SDK to the newer google-genai SDK, ensuring compatibility with the latest library features and practices.
  • API Key Management: API key handling has been updated to leverage google.colab.userdata, providing a more secure method for managing sensitive credentials within the notebook environment.
  • Notebook Formatting and Execution: The notebook has undergone linting and formatting (nbfmt), and all cells have been re-executed, updating the saved outputs for package installations and model listings.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +302 to +308
"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()])"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

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

  1. 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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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

  1. The style guide states that if execution_count is not null, 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\""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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

  1. The style guide specifies that the SDK should be installed with a minimum version, such as >=1.0.0, to guarantee feature availability.

@Aarchi-07
Copy link
Author

I was unable to migrate the "Authenticate with the Python SDK by service account key" section and would appreciate any guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:quickstarts Issues/PR referencing quickstarts folder status:awaiting review PR awaiting review from a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant