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.Interface
No new interfaces are introduced.
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
I'll start by exploring the repository structure to understand the codebase and then look at how the codex agent implements OAuth credential injection.
Assistant
Now let me look at the gemini_cli agent:
Assistant
Now let me look at the test files:
Assistant
Now let me look at the existing gemini_cli test file and the base agent to understand the structure.
Assistant
Let me look at the base agent class and the conftest:
Assistant
Let me look at the conftest and understand the gemini-cli oauth_creds.json format:
Assistant
Let me look at the BaseAgent class and check the
model_namehandling:Assistant
Now I have a good understanding. Let me implement the changes. First, let me update the imports and add class constants:
Assistant
So
EnvironmentPathsis not imported in gemini_cli.py. The codex usesEnvironmentPaths.agent_dir. Let me check what gemini uses - it hardcodes/logs/agent/. Let me check EnvironmentPaths.Assistant
Now let me open the file and make the edits:
Assistant
Now let me update the imports:
Assistant
Let me use the
replacecommand instead:Assistant
Now let me add the class constants. Let me add
_REMOTE_GEMINI_SECRETS_DIRafter the CLI_FLAGS:Assistant
Now let me view the run method region to add the
_resolve_oauth_creds_pathmethod and modifyrun:Assistant
Now let me add the
_resolve_oauth_creds_pathmethod before_build_settings_commandand modify therunmethod:Assistant
Let me check if
osis still used anywhere in the file:Assistant
osis no longer used. Let me remove the unused import:Assistant
Let me reorder the import to follow isort conventions (utils after models):
Assistant
Now I need to add the
parse_bool_env_valueimport back after the trajectories import:Assistant
Now let me view the run method to verify it's correct:
Assistant
The implementation looks good. Now let me create a temporary test script to verify the behavior, mirroring the codex auth tests:
Assistant
I need to use the venv. Let me check how to run tests in this repo.
Assistant
The
temp_dirfixture is in the tests conftest. Let me put the test file inside the tests directory temporarily:Assistant
All 19 tests pass. Now let me run the existing gemini and codex tests to make sure nothing broke:
Assistant
All tests pass. Let me also check if there are any other tests or references that might be affected by changing
os.environtoself._get_env:Assistant
Let me check
test_agent_skills.pysince it referencesGEMINI_API_KEY:Assistant
Let me run the agent_skills test and the broader installed agents test suite:
Assistant
Let me run the full installed agents test suite to make sure nothing is broken:
Assistant
All 582 tests pass. Now let me check for any linting configuration and run lint on the modified file:
Assistant
Let me check if there's documentation that mentions the codex auth env vars that should be updated for gemini:
Assistant
Let me check the claude_code.py implementation for reference to ensure consistency:
Assistant
Let me review the final diff:
Assistant
The diff looks clean. Let me verify the temp test file is removed and check overall git status:
Assistant
Let me do a final sanity check that the module imports cleanly and run a final broader test:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.