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
Now let me check
parse_bool_env_valueand the existing gemini tests: - Assistant
Now I'll implement the OAuth credential injection in
gemini_cli.py, mirroring the codex pattern: - Assistant
Now add
_resolve_oauth_creds_pathbeforerun(): - Assistant
Now add best-effort cleanup of the injected credential in the
finallyblock: - Assistant
Now write the tests, ported from
test_codex_auth.py: - Assistant
All 712 agent unit tests pass. Let me check if the codex auth pattern is documented anywhere that should mention gemini too:
- Assistant
Done. The codex flags aren't documented outside code/tests, so no docs changes are needed for parity.
Summary
src/harbor/agents/installed/gemini_cli.py— added opt-in OAuth-credential injection mirroring the codexauth.jsonflow:_resolve_oauth_creds_path()(gemini_cli.py:683) — same priority logic as codex's_resolve_auth_json_path:GEMINI_OAUTH_CREDS_PATH=<path>→ use that specific file (raises on missing file)GEMINI_FORCE_OAUTH=<truthy>→ use~/.gemini/oauth_creds.json(raises if absent; invalid bool values raise viaparse_bool_env_value)- Default:
None— existing / Vertex env behavior, fully unchanged
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.