← Back to PRs

#7781: fix: resolve Google Gemini CLI auth credential extraction #4585

by ManojPanda3 open 2026-02-03 06:11 View on GitHub →
extensions: google-gemini-cli-auth stale size: M
## 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