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 check
parse_bool_env_valueandEnvironmentPathsused in gemini_cli.py, and note that gemini_cli doesn't currently importEnvironmentPathsorparse_bool_env_value. Let's check those imports in codex.py more closely, and also checkupload_file/exec_as_rootsignatures.Assistant
Now let's add the necessary imports and implementation.
Assistant
Now let's add the
_REMOTE_GEMINI_SECRETS_DIRclass constant and the_resolve_oauth_creds_pathmethod.Assistant
Now let's add the
_resolve_oauth_creds_pathmethod, placed near_build_settings_command(beforerun).Assistant
Now let's view the full updated run method and check for syntax correctness.
Assistant
This looks good. Now let's write a quick temporary test script to verify behavior, mirroring the codex auth tests but adapted for gemini_cli, then run it and delete afterward.
Assistant
All manual verification tests pass. Now clean up the temp script and run existing test suite for gemini_cli.
Assistant
All existing tests pass. Let's run the full agent test suite for installed agents to be thorough.
Assistant
All 695 tests pass. Now let's check if there's any documentation mentioning env vars for gemini-cli (like a README or docs) that should be updated to mirror codex's documentation.
Assistant
That's a different simpler mechanism (env var passthrough), not a file-based approach — not directly relevant. Now let's view the full diff for review.
Assistant
Only the intended file is modified. Let's run the full test suite once more (broader scope) to be safe, then finalize.
Assistant
Full test suite passes (2503 passed, 1 skipped, unrelated to my change). Let's now go through the checklist.
Assistant
Checklist review:
-
If an error was reported in the issue description, I have successfully reproduced it. — This issue is a feature request, not a bug report; there's no error to reproduce. Instead, I confirmed the gap existed: before my change, had no /OAuth injection logic at all (verified by reading the file), analogous to how / work in .
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.