fix(gemini): refresh OAuth tokens on Homebrew-installed gemini-cli#401
Merged
robinebers merged 2 commits intoApr 28, 2026
Merged
Conversation
Homebrew bundles gemini-cli into @google/gemini-cli/bundle/chunk-*.js (hash names vary per version). The plugin only searched for oauth2.js, so refresh silently failed and the access token expired into misleading "session expired" errors. - Scan STATIC_NESTED_ONLY + /@google/gemini-cli/bundle/chunk-*.js as additional OAuth client-cred candidates - Fix error messages: "gemini auth login" doesn't exist; tell users to re-run "gemini" and complete the OAuth prompt - Add regression test covering the Homebrew bundle layout Fixes robinebers#384 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
🤖 Augment PR SummarySummary: Fix Gemini plugin token refresh for Homebrew-installed gemini-cli where OAuth creds are bundled into chunk files (no oauth2.js).
host.fs.listDir since hashes vary by version.
🤖 Was this summary useful? React with 👍 or 👎 |
The warning path now includes bundle chunks, so "failed reading oauth2.js at .../chunk-XXX.js" was misleading. Addresses augmentcode PR review nit on robinebers#401. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
validatedev
approved these changes
Apr 24, 2026
Owner
|
Thank you! |
barramee27
pushed a commit
to barramee27/crossusage
that referenced
this pull request
Apr 28, 2026
The warning path now includes bundle chunks, so "failed reading oauth2.js at .../chunk-XXX.js" was misleading. Addresses augmentcode PR review nit on robinebers#401. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> (cherry picked from commit 1a91101)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #384 — Gemini plugin fails to refresh OAuth tokens when
gemini-cliis installed via Homebrew, producing misleading "Gemini session expired. Run `gemini auth login`..." errors (a command that doesn't exist).Root cause:
loadOauthClientCreds()only searched foroauth2.jsat known install paths. Homebrew-installedgemini-cli(verified on v0.38.2) bundles everything into@google/gemini-cli/bundle/chunk-*.js— nooauth2.jsexists.refreshToken()returnednullsilently, the access token expired, and API calls threw "session expired".Changes
plugins/gemini/plugin.jsSTATIC_NESTED_ONLY+/@google/gemini-cli/bundle/chunk-*.jsas OAuth cred candidates (chunk hashes change per version, so we can't hardcode filenames)"Run \gemini auth login`..."messages with"Run `gemini` and re-authenticate when prompted."(per [docs](https://geminicli.com/docs/get-started/authentication/), Gemini CLI has noauth loginsubcommand — users just re-rungemini`)plugins/gemini/plugin.test.jsTest plan
bun run test plugins/gemini/plugin.test.js)gemini-cliv0.38.2:expiry_date = 1in~/.gemini/oauth_creds.jsonprobe()scanned bundle → found creds inchunk-EA775AOR.js→POST oauth2.googleapis.com/tokenreturned 200 →loadCodeAssistandretrieveUserQuotareturned 200 with new token →expiry_dateupdated,access_tokenrotated, Pro/Flash usage rendered correctly🤖 Generated with Claude Code
Summary by cubic
Fixes OAuth token refresh when
gemini-cliis installed via Homebrew by scanning bundled chunk files and updating error messages to direct users to re-rungemini. Prevents false “session expired” errors and restores API calls..../@google/gemini-cli/bundle/chunk-*.jsfor OAuth client creds whenoauth2.jsisn’t present (Homebrew layout).gemini auth login” with “Rungeminiand re-authenticate when prompted,” and clarify warn logs to refer to an OAuth “candidate” path (covers bundle chunks).Written for commit 1a91101. Summary will update on new commits.