[FEATURE]: Add Gemini CLI OAuth login flow integration #4963

Open
opened 2026-02-16 17:47:05 -05:00 by yindo · 0 comments
Owner

Originally created by @mgpai22 on GitHub (Jan 12, 2026).

Originally assigned to: @thdxr on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Summary

Add support for authenticating with Gemini using the same OAuth login flow as the official Gemini CLI. This
enables users to authenticate with their Google account directly, matching the experience provided by
gemini-cli.

Problem

Currently, Gemini authentication in OpenCode requires manual API key configuration. The official Gemini CLI
uses an OAuth flow that provides a smoother user experience with browser-based Google account login.

Proposed Solution

Integrate the Gemini CLI OAuth flow into OpenCode's plugin system:

  • Implement PKCE-based OAuth flow for secure authentication
  • Handle token exchange and refresh automatically
  • Cache access tokens with proper expiry handling
  • Support both interactive (browser) and headless authentication modes
  • Manage GCP project context for API requests

Implementation

The implementation adds a new gemini plugin under packages/opencode/src/plugin/gemini/ with:

  • oauth.ts - OAuth authorization and token exchange
  • token.ts - Token refresh logic
  • cache.ts - Access token caching
  • auth.ts - Auth state helpers
  • project.ts - GCP project management
  • request.ts / request-helpers.ts - Authenticated API requests
  • server.ts - Local callback server for OAuth redirect
  • index.ts - Plugin entry point

Verification

  • Test OAuth flow in browser-enabled environment
  • Test token refresh after expiry
  • Verify API requests work with obtained credentials
Originally created by @mgpai22 on GitHub (Jan 12, 2026). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request ## Summary Add support for authenticating with Gemini using the same OAuth login flow as the official Gemini CLI. This enables users to authenticate with their Google account directly, matching the experience provided by `gemini-cli`. ## Problem Currently, Gemini authentication in OpenCode requires manual API key configuration. The official Gemini CLI uses an OAuth flow that provides a smoother user experience with browser-based Google account login. ## Proposed Solution Integrate the Gemini CLI OAuth flow into OpenCode's plugin system: - Implement PKCE-based OAuth flow for secure authentication - Handle token exchange and refresh automatically - Cache access tokens with proper expiry handling - Support both interactive (browser) and headless authentication modes - Manage GCP project context for API requests ## Implementation The implementation adds a new `gemini` plugin under `packages/opencode/src/plugin/gemini/` with: - `oauth.ts` - OAuth authorization and token exchange - `token.ts` - Token refresh logic - `cache.ts` - Access token caching - `auth.ts` - Auth state helpers - `project.ts` - GCP project management - `request.ts` / `request-helpers.ts` - Authenticated API requests - `server.ts` - Local callback server for OAuth redirect - `index.ts` - Plugin entry point ## Verification - Test OAuth flow in browser-enabled environment - Test token refresh after expiry - Verify API requests work with obtained credentials
yindo added the discussion label 2026-02-16 17:47:05 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4963