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.
Assistant
Let me start by exploring the repository structure to understand what we're working with. This appears to be a "harbor" repository that contains agents including codex, gemini-cli, and claude-code. I need to understand the structure first.
The issue is about adding OAuth credential injection to the gemini-cli agent, mirroring the codex auth flow. Let me explore the codebase.
Assistant
Let me explore the structure more, especially the adapters directory since this seems to be where the agent implementations live.
Assistant
Let me look at the src directory and find files related to codex and gemini-cl
Assistant
Let me explore the harbor source directory.
Assistant
Let me look at the agents directory since that's where the codex and gemini-cli agents likely live.
Assistant
Let me look at the installed directory.
Assistant
Now let me look at the codex.py and gemini_cli.py files to understand the current auth flow for codex and what's missing in gemini_cl
Assistant
Let me look at the full codex auth flow and also the gemini_cli auth setup
Assistant
Now let me look at the gemini_cli.py to understand its current auth setup:
Assistant
Let me look at the full auth section in gemini_cli.py
Assistant
Let me also look at the test files for codex auth and see if there are similar tests for gemini_cli
Assistant
Let me look at the test_codex_auth.py to understand the testing pattern.
Assistant
Now let me look at the existing gemini_cli.py test file and the full gemini_cli.py agent
Assistant
Now let me look at the full gemini_cli.py to understand its structure:
Assistant
Let me look at the full codex.py to understand the complete auth flow including the remote paths and how they're used
Assistant
Now let me look at the base class and how
_get_envandparse_bool_env_valueworkAssistant
Let me look at the full codex run method:
Assistant
Let me look at
EnvironmentPaths.agent_dirAssistant
Now let me also see how
parse_bool_env_valueworks:Assistant
Now let me look at the full codex.py beginning section to understand the imports and class structure
Assistant
Now I have a clear understanding of the pattern. Let me implement the changes.
First, let me look at the imports and the complete gemini_cli.py to understand everything I need to
Assistant
Let me open the gemini_cli.py file to make my edits.
Assistant
Let me try using the open command properly with the required syntax.
Assistant
Let me look at the gemini_cli run method and the complete file
Assistant
Now I have a good understanding of the codebase. Let me implement the OAuth credential injection for gemini-cli, mirroring the codex auth flow. Here's my plan:
- Add
PurePosixPathimport andparse_bool_env_valueimport - Add
_REMOTE_GEMINI_SECRETS_DIRclass constant - Add
_resolve_oauth_creds_pathmethod - Modify the
runmethod to upload oauth creds and place them in~/.gemini/
Let me start with the imports
- Add
Assistant
Let me use the replace command instead
Assistant
Now let me add the
parse_bool_env_valueimportAssistant
Now let me add the
_REMOTE_GEMINI_SECRETS_DIRclass constant afterCLI_FLAGSAssistant
Now let me add the
_resolve_oauth_creds_pathmethod. Let me find the right location after theinstallAssistant
Let me insert the
_resolve_oauth_creds_pathmethod between the install and_save_imagemethodsAssistant
Now I need to modify the
runmethod. Let me look at it againAssistant
Let me see the whole run method
Assistant
Now I'll modify the
runmethod to add OAuth credential injection. Let me replace the auth sectionAssistant
Let me check the exact text at line 696
Assistant
Let me check the exact lines
Assistant
Let me use
editwith the proper line rangeAssistant
I see there's a missing
if skills_command:block after my edit. Let me fixAssistant
Let me fix the missing `if skills_command
Assistant
Good! Now let me verify the file is syntactically correct and then write the
Assistant
The file compiles successfully. Now let me create the tests for gemini_cli auth, mirroring the codex auth tests.
Assistant
Now let me create the test file for gemini_cli auth
Assistant
Let me create the test file using bash
Assistant
Now let me run the tests to make sure they pass
Assistant
Let me check how tests are typically run in this project
Assistant
Let me check the virtual environment and install the package
Assistant
Let me install the package in development mode
Assistant
Now let me run the tests
Assistant
Let me check the pytest configuration and conftest
Assistant
Let me check the installed pytest and see if it supports
asyncio_modeAssistant
Let me check for pytest-asyncio
Assistant
Let me try running the existing codex auth tests first to see if tests work at
Assistant
Let me install pytest-asyncio
Assistant
Let me try running the tests now
Assistant
Now let me run my gemini_cli auth tests
Assistant
Let me fix the failing test - the
envcan be None in some callsAssistant
Let me run the tests again
Assistant
All 18 tests pass. Let me also run the existing gemini_cli tests and codex auth tests to make sure nothing is broken
Assistant
All 58 tests pass. Let me verify the final state of the implementation
Assistant
Let me do a final review by looking at the diff of changes
Assistant
Let me also check the new test file
Assistant
Let me check the overall state of changes
Assistant
Let me quickly verify
_get_envbehavior to make sureextra_envworks correctly
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.