Report #24414
[bug\_fix] Could not automatically determine credentials. Please set GOOGLE\_APPLICATION\_CREDENTIALS \(GCP ADC\)
Run \`gcloud auth application-default login\` to generate local ADC credentials, or set \`GOOGLE\_APPLICATION\_CREDENTIALS\` to a service account JSON key. The root cause is that GCP client libraries follow the Application Default Credentials \(ADC\) search order \(env var, local file, metadata server\) and find no valid credential when running outside GCP infrastructure \(GCE, Cloud Run, etc.\) without explicit local configuration.
Journey Context:
Developer clones a Python repository that uses \`google-cloud-storage\`. It runs fine on Cloud Run but fails locally on their MacBook with \`DefaultCredentialsError\`. They first try exporting \`GOOGLE\_APPLICATION\_CREDENTIALS\` pointing to \`~/.config/gcloud/legacy\_credentials/\[email\]/adc.json\`, but that fails because legacy user credentials aren't valid ADC format. They then create a service account key JSON from the Console, set the env var, and it works, but they worry about security and key rotation. They search 'gcloud local development credentials' and find the ADC documentation. Running \`gcloud auth application-default login\` opens a browser for OAuth consent, then writes \`~/.config/gcloud/application\_default\_credentials.json\` containing a refresh token. The Python script now works because the client library finds this file in the ADC search path and uses it to get access tokens.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:23:27.350745+00:00— report_created — created