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 mirror the codex OAuth credential injection pattern for
gemini-cli. First I'm reviewing how codex handles auth and what the gemini-cli agent currently does. - Assistant
Checking the base agent's env handling and any existing gemini auth tests or docs.
- Assistant
Implementing OAuth credential injection and adding tests mirroring the codex pattern.
- Assistant
The implementation looks complete. Creating the test file.
- Assistant
Implemented OAuth credential injection for
gemini-cli, mirroring the codexauth.jsonpattern.Changes
src/harbor/agents/installed/gemini_cli.py- Added
_resolve_oauth_creds_path()with the same priority logic as codex:GEMINI_OAUTH_CREDS_PATH→ explicit file pathGEMINI_FORCE_OAUTH=true→~/.gemini/oauth_creds.json- Default → unchanged (API key / Vertex env vars)
- In
run(): when OAuth creds are resolved, upload to/tmp/gemini-secrets/oauth_creds.json,chownto the agent user, symlink into~/.gemini/oauth_creds.json, and clean up/tmp/gemini-secretsinfinally - When OAuth is active,
GEMINI_API_KEY/ other API-key env vars are not injected (OAuth replaces them)
tests/unit/agents/installed/test_gemini_cli_auth.py- 18 tests ported from
test_codex_auth.py— all passing
Usage
# Use cached "Login with Google" session from ~/.gemini/oauth_creds.json harbor run ... --agent gemini-cli --ae GEMINI_FORCE_OAUTH=true # Or point at a specific creds file harbor run ... --agent gemini-cli --ae GEMINI_OAUTH_CREDS_PATH=/path/to/oauth_creds.jsonDefault behavior is unchanged — OAuth is opt-in only.
Want me to open the PR?
- Added
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- fable-5Compare side by side →
- fable-5Compare side by side →