ISSUE DESCRIPTION gemini-cli: support Login with Google (oauth-personal), mirroring…
- User
ISSUE DESCRIPTION
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.ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /harbor, current file: none) bash-$
Assistant
Let me start by exploring the repository structure to understand what we're working with. The issue is about adding OAuth credential injection to
gemini-cli, mirroring the codex auth.json pattern. Let me first explore the repository structure.Let me look at the repository layout, understand the codebase, and find the relevant files.
Assistant
This looks like a monorepo. Let me explore the structure more. The issue mentions
codexandgemini-cliagents. Let me look at the adapters directory since this seems to be where agents are defined.Assistant
Let me look for the codex and gemini-cli adapters specifically.
Assistant
No results for codex or gemini in adapters. Let me search more broadly.
Assistant
Let me search for codex and gemini related files in the source code
Assistant
Let me look at the key files:
Assistant
Now let me look at the gemini_cli.py file to see how it currently
Assistant
Now let me look at the codex auth test file to understand how tests are written
Assistant
Now let me also look at some key supporting files:
Assistant
Now let me look at the existing tests for gemini_cli:
Assistant
Let me look at the utility function for parsing boolean
Assistant
Now let me also check the conftest.py for test fixtures
Assistant
Let me also check what environment variable the Gemini CLI uses for OAuth credentials.
Assistant
Let me look at how claude_code handles OAuth tokens for reference:
Assistant
Now I have a good understanding. Let me implement the changes. I need to:
- Add
_resolve_oauth_creds_path()toGeminiCli - Modify
run()to handle OAuth credentials - Create tests in
tests/unit/agents/installed/test_gemini_cli_oauth.py
Let me first look at the full
run()method in gemini_cli.py to understand where to insert the changes:- Add
Assistant
Let me try opening again.
Assistant
Let me scroll to see the run method:
Assistant
Let me scroll further to see the
run()method:Assistant
Let me see the rest of the file
Assistant
Now let me check the import for
parse_bool_env_valuein codex.pyAssistant
Now I have a full understanding. Let me implement the changes:
Plan:
- Add
from harbor.utils.env import parse_bool_env_valueimport - Add
_resolve_oauth_creds_path()method that mirrors_resolve_auth_json_path() - Modify
run()to upload OAuth creds when available - Create
test_gemini_cli_oauth.pymirroringtest_codex_auth.py
Let's
- Add
Assistant
Let me use replace to add the import line
Assistant
Let me use a Python script to make the changes:
Assistant
Let me verify the changes were made correctly
Assistant
Let me check the full run method to see if the OAuth upload looks correct
Assistant
I see an issue - the
$HOMEwas stripped. Let me fix the remote paths:Assistant
Let me verify the fix
Assistant
Let me verify the
_resolve_oauth_creds_pathmethod:Assistant
Now let me create the test file mirroring test_codex_auth.py
Assistant
Now let me run the tests to make sure everything works
Assistant
Let me check how tests are usually run in this project
Assistant
Let me install the package in development mode
Assistant
Now let me run the tests again
Assistant
Let me check the pytest configuration:
Assistant
Let me check the pytest-asyncio package
Assistant
Let me check if there's a venv that should be used
Assistant
Let me use the venv to run
Assistant
All 17 tests pass. Now let me also run the existing gemini_cli tests to make sure nothing is broken
Assistant
Let me also run the codex auth tests to make sure they still pass
Assistant
Let me also run the full agent tests to make sure nothing else is broken:
Assistant
All tests pass. Let me also run the gemini CLI MCP tests
Assistant
Let me do a final review of the changes by looking at the diff:
Assistant
Let me also check the new test file:
Assistant
The new test file is untracked. Let me verify it exists:
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
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →