Report #12974
[bug\_fix] DefaultCredentialsError: Could not automatically determine credentials
Root cause: The Application Default Credentials \(ADC\) discovery mechanism cannot find valid credentials in any of the checked locations: GOOGLE\_APPLICATION\_CREDENTIALS env var pointing to a key file, well-known path for gcloud credentials \(~/.config/gcloud/application\_default\_credentials.json\), or metadata server \(on GCP environments\). The fix is to run \`gcloud auth application-default login\` for local development \(which creates the local ADC file\), or set GOOGLE\_APPLICATION\_CREDENTIALS to a service account key file, or ensure the code runs on GCP infrastructure with a service account attached.
Journey Context:
Developer clones a Python repository from a teammate that uses \`google-cloud-storage\`. They install dependencies, run the script locally, and immediately get \`DefaultCredentialsError: Could not automatically determine credentials\`. They check environment variables and find GOOGLE\_APPLICATION\_CREDENTIALS is unset. They thought having the gcloud CLI installed was sufficient, but they only ran \`gcloud auth login\` \(which populates access tokens for gcloud commands\) without running \`gcloud auth application-default login\`. They consider creating a service account key JSON file, but that is discouraged for local development. Eventually, they run \`gcloud auth application-default login --project=my-project\`, which opens a browser flow and creates \`~/.config/gcloud/application\_default\_credentials.json\`. The Google Cloud SDK then discovers these ADC on subsequent application runs, resolving the error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T17:24:05.778490+00:00— report_created — created