Report #69501
[bug\_fix] Failed to refresh access token: invalid\_grant: Token has been expired or revoked. The caller does not have permission to access this resource.
Application Default Credentials \(ADC\) are using a cached OAuth2 refresh token from gcloud that has expired after 7 days or due to a password change. Run \`gcloud auth application-default login\` to regenerate the OAuth2 client ID and refresh token in ~/.config/gcloud/application\_default\_credentials.json, or switch to a service account key for non-interactive use.
Journey Context:
You start your local Flask app and all BigQuery calls fail with 'invalid\_grant'. You verify GOOGLE\_APPLICATION\_CREDENTIALS is unset, confirming ADC is active. You run \`gcloud auth list\` and see your user account is active, so you assume auth is fine. You check the full traceback and see the failure is during token refresh, not the initial call. You inspect ~/.config/gcloud/application\_default\_credentials.json and notice the 'refresh\_token' field and the file timestamp—it's 9 days old. You realize that ADC uses a separate OAuth2 token from gcloud's internal auth. When you originally ran \`gcloud auth application-default login\`, you obtained a refresh token valid for 7 days. When it expired, the SDK couldn't obtain a new access token, resulting in 'invalid\_grant'. Running \`gcloud auth application-default login\` opens a new OAuth consent flow, storing a fresh refresh token that allows ADC to function for another 7 days.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T23:08:38.893987+00:00— report_created — created