Skip to content

Route Gemini OAuth through @google/genai SDK - #25

Merged
rafaeelricco merged 8 commits into
mainfrom
cursor/gemini-oauth-sdk-path
May 17, 2026
Merged

Route Gemini OAuth through @google/genai SDK#25
rafaeelricco merged 8 commits into
mainfrom
cursor/gemini-oauth-sdk-path

Conversation

@rafaeelricco

Copy link
Copy Markdown
Owner

Summary

  • Replace the raw fetch Gemini OAuth path with GoogleGenAI so OAuth uses the same httpOptions as API-key calls: 120s timeout and three retry attempts.
  • Authenticate OAuth via Authorization: Bearer <access_token> in httpOptions.headers; use a placeholder apiKey only to satisfy the SDK constructor without sending a real API key on the wire.
  • Remove the REST-only request body builder and the response.json() cast to GenerateContentResponse, so responses stay SDK-parsed and aligned with the API-key path.

Test plan

  • pnpm run typecheck and pnpm run lint:ci
  • With Gemini configured for Google OAuth, run the commit flow and confirm a message is generated and request metadata (model, duration, tokens when present) still appears in notes.
  • (Optional) Confirm transient failures retry instead of failing on the first attempt.

Use GoogleGenAI httpOptions for timeout and retries instead of raw fetch,
removing the REST JSON cast.
@rafaeelricco
rafaeelricco marked this pull request as ready for review May 16, 2026 23:24
@rafaeelricco
rafaeelricco marked this pull request as ready for review May 16, 2026 23:24

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5832970e65

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/infra/llm/gemini.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5832970e65

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/infra/llm/gemini.ts Outdated
Drop the placeholder apiKey (NodeAuth always appends the key header when
apiKey is set). Temporarily unset GEMINI/GOOGLE API key env vars during the
OAuth SDK call so implicit env keys cannot add the header either.
@rafaeelricco

Copy link
Copy Markdown
Owner Author

Pushed abbb727 addressing the Codex review: NodeAuth.addAuthHeaders always appends x-goog-api-key when apiKey is set (even after Authorization), so the placeholder apiKey path was wrong.

OAuth now constructs GoogleGenAI without apiKey, only httpOptions.headers.Authorization. During that call we temporarily unset GEMINI_API_KEY / GOOGLE_API_KEY so the SDK cannot pick up an implicit API key from the environment and add the header for OAuth-only runs.

Follows the Gemini OAuth SDK follow-up fix.
Add a CLI Version row from package.json and build rows with concat.
Annotate prefix rows as CheckRow[] then concat so tsc accepts renderTable input.
@rafaeelricco rafaeelricco self-assigned this May 17, 2026
Bracket OAuth and model fetch under bracketStatus with phased status
messages, fix the OAuth race timeout, resolve email via getTokenInfo,
drop forced consent on re-auth, and soften the browser success copy.
@rafaeelricco
rafaeelricco merged commit c47aafb into main May 17, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant