plans/gemini-oauth-provider.md
Add a first-class gemini provider that authenticates via Google OAuth, using the standard Gemini API (not Cloud Code Assist). Users who have a Google AI subscription or Gemini API access can authenticate through the browser without needing to manually copy API keys.
generativelanguage.googleapis.com/v1betacloudcode-pa.googleapis.com) — rate-limited free tier, internal API, account ban riskchat_completions api_mode via OpenAI SDK — no new api_mode neededhttps://accounts.google.com/o/oauth2/v2/authhttps://oauth2.googleapis.com/tokenhttp://localhost:8085/oauth2callback (localhost callback server)https://www.googleapis.com/auth/cloud-platform, https://www.googleapis.com/auth/userinfo.email~/.hermes/gemini_oauth.json (NOT sharing with ~/.gemini/oauth_creds.json)client_id, client_secret, refresh_token, access_token, expires_at, emailgrant_type=refresh_tokenhttps://generativelanguage.googleapis.com/v1betachat_completions (standard facade over native transport)agent/google_oauth.py — OAuth flow (PKCE, localhost server, token exchange, refresh)
start_oauth_flow() — opens browser, starts callback serverexchange_code() — code → tokensrefresh_access_token() — refresh flowload_credentials() / save_credentials() — file I/O with lockingget_valid_access_token() — check expiry, refresh if neededhermes_cli/auth.py — Add ProviderConfig for "gemini" with auth_type="oauth_google"hermes_cli/models.py — Add Gemini model cataloghermes_cli/runtime_provider.py — Add gemini branch (read OAuth token, build OpenAI client)hermes_cli/main.py — Add _model_flow_gemini(), add to provider choiceshermes_cli/setup.py — Add gemini auth flow (trigger browser OAuth)run_agent.py — Token refresh before API calls (like Copilot pattern)agent/auxiliary_client.py — Add gemini to aux resolution chainagent/model_metadata.py — Add Gemini model context lengthstests/agent/test_google_oauth.py — OAuth flow unit teststests/test_api_key_providers.py — Add gemini provider testwebsite/docs/getting-started/quickstart.md — Add gemini to provider tablewebsite/docs/user-guide/configuration.md — Gemini setup sectionwebsite/docs/reference/environment-variables.md — New env vars~400 lines new code, ~150 lines modifications, ~100 lines tests, ~50 lines docs = ~700 lines total
extensions/google/oauth.flow.ts (PKCE + localhost server)packages/ai/src/utils/oauth/google-gemini-cli.ts (same flow)hermes_cli/main.py _copilot_device_flow() (different flow type but same lifecycle pattern)