#7781: fix: resolve Google Gemini CLI auth credential extraction #4585
extensions: google-gemini-cli-auth
stale
size: M
Cluster:
OAuth and CLI Fixes
## Description
This PR fixes an authentication failure in the `google-gemini-cli-auth` extension where the onboarding process was failing to find and extract local credentials.
## Changes
- **Fixed Filename:** Updated `findFile` to look for `gemini.js` (the correct filename) instead of `oauth2.js`.
- **Improved Regex:** Updated `idMatch` logic to correctly capture the `OAUTH_CLIENT_ID` from the file content, ensuring compatibility with the current credential format.
- **Error Handling:** Added empty `catch` blocks to prevent the process from crashing if a file search or read fails.
## Related Issue
Closes #4585
## Testing Done
- Environment: Arch Linux / CachyOS.
- Verified by running `pnpm openclaw onboard`.
- Confirmed that the Gemini/Google provider now successfully identifies the local credentials and completes the authentication flow.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates the Gemini CLI credential extraction logic to fix onboarding auth failures by searching for the correct bundled filename (`gemini.js`) and tightening the client-id match to the `OAUTH_CLIENT_ID` assignment before proceeding with the existing OAuth flow.
The changes live entirely in `extensions/google-gemini-cli-auth/oauth.ts`, which is responsible for locating an installed `gemini` binary, extracting OAuth client credentials from the CLI’s installed files, then running a localhost callback-based OAuth flow (with a manual fallback for remote/WSL2 environments).
<h3>Confidence Score: 4/5</h3>
- This PR is likely safe to merge; changes are small and localized to credential extraction.
- The update fixes an obvious filename mismatch and narrows the client-id match to a specific assignment. Main risk is future upstream format changes making the regex too strict or comments/formatting drift, but there are no clear runtime regressions introduced beyond potentially missing matches in some environments.
- extensions/google-gemini-cli-auth/oauth.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#6045: fix(auth): fix Gemini CLI path detection for global npm installs on...
by ehgamemo · 2026-02-01
85.9%
#5027: fix(auth): use correct OAuth credentials for google-gemini-cli refresh
by shayan919293 · 2026-01-30
85.0%
#10372: Fix google-gemini-cli-auth to work on Windows
by omribahumi · 2026-02-06
84.9%
#4550: fix: sync google-gemini-cli-auth tokens from external CLI (#3803)
by SalimBinYousuf1 · 2026-01-30
84.0%
#3521: fix(gemini-auth): handle mise shims and nested node_modules paths
by sebslight · 2026-01-28
83.9%
#2657: fix: use TLS 1.2 for gemini-cli and google-antigravity OAuth reques...
by PrentissLiu · 2026-01-27
81.4%
#16786: fix: support google-antigravity OAuth for Gemini embeddings
by outsourc-e · 2026-02-15
78.8%
#2535: fix(google-antigravity): use 127.0.0.1 instead of localhost for OAu...
by brian033 · 2026-01-27
78.7%
#21835: fix: apply schema cleaning for google-antigravity in normalizeToolP...
by ephraimm · 2026-02-20
77.8%
#5064: fix(auth): update deprecated User-Agent headers
by mfortin014 · 2026-01-31
77.8%