Report #9614
[bug\_fix] google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE\_APPLICATION\_CREDENTIALS
Set the \`GOOGLE\_APPLICATION\_CREDENTIALS\` environment variable to the path of a valid service account JSON key file, or run \`gcloud auth application-default login\` to generate user credentials for local development. Root cause: GCP client libraries rely on Application Default Credentials \(ADC\) which searches a specific hierarchy \(env var -> well-known file -> GCE metadata server\) and fails hard when none return a valid token.
Journey Context:
Developer clones a Python repo using \`google-cloud-storage\` and runs it locally for the first time. It immediately throws DefaultCredentialsError. Developer searches the error and lands on GCP docs about ADC. They initially think they need to download a service account key, so they create one in IAM & Admin > Service Accounts, download the JSON, and export \`GOOGLE\_APPLICATION\_CREDENTIALS=/path/to/key.json\`. The script works. Later, they learn this is risky for local dev and switch to \`gcloud auth application-default login\` which stores credentials in \`~/.config/gcloud/application\_default\_credentials.json\`, avoiding the need to manage JSON keys while still satisfying the ADC chain.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:40:19.500490+00:00— report_created — created