-
Couldn't load subscription status.
- 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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -255,7 +255,7 @@ | |
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "execution_count": 2, | ||
| "metadata": { | ||
| "id": "9OEoeosRTv-5" | ||
| }, | ||
|
|
@@ -264,13 +264,14 @@ | |
| "name": "stdout", | ||
| "output_type": "stream", | ||
| "text": [ | ||
| "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m137.4/137.4 kB\u001b[0m \u001b[31m2.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", | ||
| "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m45.3/45.3 kB\u001b[0m \u001b[31m2.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | ||
| "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m236.7/236.7 kB\u001b[0m \u001b[31m12.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | ||
| "\u001b[?25h" | ||
| ] | ||
| } | ||
| ], | ||
| "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 commentThe reason will be displayed to describe this comment to others. Learn more. The SDK package name has been correctly updated to Style Guide ReferencesFootnotes
|
||
| ] | ||
| }, | ||
| { | ||
|
|
@@ -284,15 +285,27 @@ | |
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "execution_count": 5, | ||
| "metadata": { | ||
| "id": "TS9l5igubpHO" | ||
| }, | ||
| "outputs": [], | ||
| "outputs": [ | ||
| { | ||
| "name": "stdout", | ||
| "output_type": "stream", | ||
| "text": [ | ||
| "Available base models: ['models/embedding-gecko-001', 'models/gemini-2.5-pro-preview-03-25', 'models/gemini-2.5-flash-preview-05-20', 'models/gemini-2.5-flash', 'models/gemini-2.5-flash-lite-preview-06-17', 'models/gemini-2.5-pro-preview-05-06', 'models/gemini-2.5-pro-preview-06-05', 'models/gemini-2.5-pro', 'models/gemini-2.0-flash-exp', 'models/gemini-2.0-flash', 'models/gemini-2.0-flash-001', 'models/gemini-2.0-flash-exp-image-generation', 'models/gemini-2.0-flash-lite-001', 'models/gemini-2.0-flash-lite', 'models/gemini-2.0-flash-preview-image-generation', 'models/gemini-2.0-flash-lite-preview-02-05', 'models/gemini-2.0-flash-lite-preview', 'models/gemini-2.0-pro-exp', 'models/gemini-2.0-pro-exp-02-05', 'models/gemini-exp-1206', 'models/gemini-2.0-flash-thinking-exp-01-21', 'models/gemini-2.0-flash-thinking-exp', 'models/gemini-2.0-flash-thinking-exp-1219', 'models/gemini-2.5-flash-preview-tts', 'models/gemini-2.5-pro-preview-tts', 'models/learnlm-2.0-flash-experimental', 'models/gemma-3-1b-it', 'models/gemma-3-4b-it', 'models/gemma-3-12b-it', 'models/gemma-3-27b-it', 'models/gemma-3n-e4b-it', 'models/gemma-3n-e2b-it', 'models/gemini-flash-latest', 'models/gemini-flash-lite-latest', 'models/gemini-pro-latest', 'models/gemini-2.5-flash-lite', 'models/gemini-2.5-flash-image-preview', 'models/gemini-2.5-flash-image', 'models/gemini-2.5-flash-preview-09-2025', 'models/gemini-2.5-flash-lite-preview-09-2025', 'models/gemini-robotics-er-1.5-preview', 'models/gemini-2.5-computer-use-preview-10-2025', 'models/embedding-001', 'models/text-embedding-004', 'models/gemini-embedding-exp-03-07', 'models/gemini-embedding-exp', 'models/gemini-embedding-001', 'models/aqa', 'models/imagen-3.0-generate-002', 'models/imagen-4.0-generate-preview-06-06', 'models/imagen-4.0-ultra-generate-preview-06-06', 'models/imagen-4.0-generate-001', 'models/imagen-4.0-ultra-generate-001', 'models/imagen-4.0-fast-generate-001', 'models/veo-2.0-generate-001', 'models/veo-3.0-generate-preview', 'models/veo-3.0-fast-generate-preview', 'models/veo-3.0-generate-001', 'models/veo-3.0-fast-generate-001', 'models/gemini-2.5-flash-preview-native-audio-dialog', 'models/gemini-2.5-flash-exp-native-audio-thinking-dialog', 'models/gemini-2.0-flash-live-001', 'models/gemini-live-2.5-flash-preview', 'models/gemini-2.5-flash-live-preview', 'models/gemini-2.5-flash-native-audio-latest', 'models/gemini-2.5-flash-native-audio-preview-09-2025']\n" | ||
| ] | ||
| } | ||
| ], | ||
| "source": [ | ||
| "import google.generativeai as genai\n", | ||
| "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()])" | ||
|
Comment on lines
+302
to
+308
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Style Guide ReferencesFootnotes
|
||
| ] | ||
| }, | ||
| { | ||
|
|
||
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_countfor this cell is set to2instead ofnull. 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.1Style Guide References
Footnotes
The style guide states that if
execution_countis notnull, it usually means the formatting script needs to be run. ↩