fix: support OAuth for Gemini media understanding#17813
Closed
irchelper wants to merge 2 commits into
Closed
Conversation
added 2 commits
February 16, 2026 14:02
Add parseGeminiAuth() to detect OAuth JSON format ({"token": "...", "projectId": "..."})
and use Bearer token authentication instead of x-goog-api-key header.
This allows OAuth users (using gemini-cli-auth extension) to use memory_search
with Gemini embedding API.
Extract parseGeminiAuth() to shared infra module and use it in both embeddings-gemini.ts and inline-data.ts. Previously, inline-data.ts directly set x-goog-api-key header without handling OAuth JSON format. Now it properly supports both traditional API keys and OAuth tokens.
Author
|
Merged into #17800 |
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.
Summary
Extract
parseGeminiAuth()to shared infra module (src/infra/gemini-auth.ts) and use it in both:src/memory/embeddings-gemini.tssrc/media-understanding/providers/google/inline-data.tsProblem
inline-data.tsdirectly setx-goog-api-keyheader without handling OAuth JSON format:This broke media understanding when using OAuth authentication (e.g.,
{"token": "...", "projectId": "..."}).Solution
src/infra/gemini-auth.tswith sharedparseGeminiAuth()functionTesting
pnpm checkpasses (format, types, lint)Greptile Summary
Extracts the
parseGeminiAuth()function fromsrc/memory/embeddings-gemini.ts(added in the prior commitac0613cf) into a sharedsrc/infra/gemini-auth.tsmodule, and applies it tosrc/media-understanding/providers/google/inline-data.tsto fix OAuth authentication for Gemini media understanding (video/image description).src/infra/gemini-auth.ts— detects OAuth JSON format ({"token": "...", "projectId": "..."}) and returnsAuthorization: Bearerheaders, falling back tox-goog-api-keyfor traditional API keys.inline-data.ts: Replaces hardcodedx-goog-api-key+content-typeheader logic withparseGeminiAuth(), fixing the bug where OAuth JSON was set as a raw API key value.embeddings-gemini.ts: Swaps the localparseGeminiAuthimplementation for the shared import (no behavioral change).Confidence Score: 5/5
Last reviewed commit: 962d59b
(5/5) You can turn off certain types of comments like style here!