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
Now let's look at the test file for codex auth to mirror it, and check
_get_envandparse_bool_env_value.Assistant
Now let's check
EnvironmentPathsandPurePosixPathusage pattern, and how gemini_cli currently doesn't useEnvironmentPaths. Let's check imports needed.Assistant
Now let's make the edits.
Assistant
Let me fix the import ordering to be alphabetical (models before utils).
Assistant
Now add class attribute for remote secrets dir and the
_resolve_oauth_creds_pathmethod.Assistant
Now add
_resolve_oauth_creds_pathmethod. Let's place it near_build_register_skills_command.Assistant
Now update
_build_settings_commandto passuse_oauth:Assistant
Now let's rewrite this section.
Assistant
Now let's add cleanup for the secrets dir in the
finallyblock, mirroring codex's best-effort removal.Assistant
Now let's verify the full run() method and check syntax.
Assistant
Looks good. Now let's write a quick reproduce/test script (temporary, not committed) mimicking test_codex_auth.py patterns to verify behavior.
Assistant
Let's write a temporary test script using pytest to validate the new functionality, run it, then delete it.
Assistant
Good, venv works. Now run our temp test.
Assistant
All 17 pass. Now remove the temp test file and run existing gemini tests plus the whole test suite for agents.
Assistant
All existing tests pass. Now let's run the full test suite for the
agents/installeddirectory to make sure nothing else broke, and also check linting.Assistant
All 582 tests pass. Let's also check linting/formatting tools used in repo (ruff, etc.)
Assistant
Now let's check mypy type checking, if configured.
Assistant
No mypy available; skip. Let's view the full diff for final review.
Assistant
No documentation references it elsewhere, so no doc changes needed. Let's also check if there's a docs directory referencing gemini-cli env vars.
Assistant
No specific documentation to update. The implementation is complete and consistent with existing patterns. Let's do a final full check of the diff and run the complete unit test suite once more to be safe.
Assistant
All 2503 unit tests pass (1 skipped unrelated). Let's clean up the temporary reproduction script and finalize.
Assistant
Only the intended file is modified. Let's do a final review of the complete diff once more for correctness.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.