Gemini CLI fixes a credential fallback bug that crashed agent mode on expired OAuth tokens

luisfelipe-alt · ghdev · 2026-07-21

Gemini CLI fix restores credential fallback when cached OAuth data is stale

A PR to google-gemini/gemini-cli fixes a regression in Gemini Code Assist Agent Mode where the client would stop after finding a cached .gemini/oauthcreds.json file and skip GOOGLEAPPLICATIONCREDENTIALS entirely.

When the cached OAuth tokens expired or failed to refresh, local dev machines could fall back to GCE metadata credentials, hang on the 169.254.169.254 metadata endpoint, and crash the agent with FatalAuthenticationError. The patch changes credential loading to try all available paths sequentially, verify each one, and keep falling back until one succeeds. It also adds a regression test covering the invalid-cache-plus-fallback case.

Original post →

More from coding & agent

coding & agent channel →