Report #50311
[bug\_fix] GCP ADC invalid authentication credentials \(HTTP 401\) when using Application Default Credentials
The gcloud-based Application Default Credentials \(stored in \`~/.config/gcloud/application\_default\_credentials.json\`\) contain an OAuth 2 refresh token that has expired or been revoked. Run \`gcloud auth application-default login\` to regenerate the JSON file with a fresh refresh token. Alternatively, if \`GOOGLE\_APPLICATION\_CREDENTIALS\` points to a deleted service account key, unset the variable and use a valid service account key file.
Journey Context:
Your Python script using \`google-cloud-storage\` worked last week but now throws 401 "invalid authentication credentials". You check \`echo $GOOGLE\_APPLICATION\_CREDENTIALS\` and it's empty. You look at \`~/.config/gcloud/application\_default\_credentials.json\` and see a \`refresh\_token\` field. You check the token info with \`curl https://oauth2.googleapis.com/tokeninfo?refresh\_token=...\` and get "invalid\_grant". You realize that when you ran \`gcloud auth application-default login\` 6 months ago, the refresh token expired after 6 months of inactivity \(or you revoked it via Google Account security settings\). The fix regenerates the ADC file, and your script works because the Google Auth library now uses the new refresh token to get access tokens.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T14:55:43.376446+00:00— report_created — created