gemini-cli: support Login with Google (oauth-personal), mirroring codex auth.json The…
- User
gemini-cli: support Login with Google (oauth-personal), mirroring codex auth.json The
codexagent injects a cached OAuth credential (~/.codex/auth.json) so runs can use a login instead of an API key (CODEX_AUTH_JSON_PATH/CODEX_FORCE_AUTH_JSON), andclaude-codeacceptsCLAUDE_CODE_OAUTH_TOKEN(#173).gemini-clihas no equivalent — it only wiresGEMINI_API_KEY/ Vertex env, so users with a "Login with Google" session (~/.gemini/oauth_creds.json) must keep a separate API key for runs.Proposal: add the same opt-in OAuth-credential injection to the
gemini-cliagent, mirroring the codex pattern —GEMINI_OAUTH_CREDS_PATH/GEMINI_FORCE_OAUTH, default behavior unchanged (fully backward-compatible).I have a working implementation that mirrors the codex auth flow (
_resolve_oauth_creds_path→ upload → chown →~/.gemini) with tests ported 1:1 fromtest_codex_auth.py, verified end-to-end (gemini-cli --ae GEMINI_FORCE_OAUTH=truecompleted hello-world, reward 1.0). Happy to open the PR or hand it off — whichever you prefer.Interface
No new interfaces are introduced.
- Assistant
I’ll inspect the existing Codex credential flow and Gemini agent/tests, then port the behavior with backward-compatible opt-in semantics and run the required unit, lint, format, and type checks.
- Assistant
rgisn’t installed in this workspace, so I’m switching to targetedfind/grepinspection and keeping the search scoped to agent code and unit tests. - Assistant
The Codex implementation uses explicit-path precedence, strict boolean parsing, a temporary secrets directory, ownership correction, and a symlink into the CLI home. I’m applying that same shape to Gemini, while leaving the API-key/Vertex path untouched when OAuth isn’t opted into.
- Assistant
The focused tests pass. One parity detail matters for “force OAuth”: when OAuth is selected, Gemini should not also receive host API-key or Vertex variables, since those can override the cached login. I’m tightening that selection before the full repository checks.
- Assistant
Implementation and tests are now formatted and lint-clean. I’m running the project-wide type check next, followed by the mandated unit suite; if either exposes an interaction outside the focused Gemini tests, I’ll address it.
- Assistant
A final local consistency review found the auth selection itself should be explicit, not inferred solely from the presence of the credential file. I’m setting Gemini CLI’s auth type to
oauth-personalonly for the opted-in path, which keeps default behavior unchanged and makesGEMINI_FORCE_OAUTHdeterministic.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.