Report #62727
[bug\_fix] DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE\_APPLICATION\_CREDENTIALS or explicitly create credentials and re-run the application.
Run \`gcloud auth application-default login\` to populate the ADC file at ~/.config/gcloud/application\_default\_credentials.json. Root cause: GCP client libraries search for Application Default Credentials in a specific hierarchy; without explicit GOOGLE\_APPLICATION\_CREDENTIALS env var or service account keys, the library expects the gcloud CLI to have generated the ADC cache file, which only occurs after running this specific login command.
Journey Context:
You're developing a Python app using google-cloud-storage. It deploys fine to Cloud Run, but locally you get this cryptic error on client initialization. You check environment variables—GOOGLE\_APPLICATION\_CREDENTIALS isn't set. You consider downloading a service account JSON key, but that feels wrong for local dev and violates your security policies. You Google and find references to 'Application Default Credentials' but the docs are ambiguous about local vs production behavior. You try \`gcloud auth login\` and verify \`gcloud auth list\` shows your account, but the Python error persists. You dig into the google-auth library source code and discover it's specifically looking for ~/.config/gcloud/application\_default\_credentials.json which doesn't exist. You finally discover that \`gcloud auth login\` \(which obtains user credentials\) is distinct from \`gcloud auth application-default login\` \(which generates the ADC file for client libraries\). You run the latter, the JSON appears, and your code works.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T11:46:13.942272+00:00— report_created — created