Report #17386
[bug\_fix] google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials
Run \`gcloud auth application-default login\` to generate the ADC file in the well-known location, or explicitly set the \`GOOGLE\_APPLICATION\_CREDENTIALS\` environment variable to a valid service account JSON key file.
Journey Context:
A developer clones a Python repository using \`google-cloud-storage\`, installs dependencies, and runs the script. It immediately fails with \`DefaultCredentialsError\`. The developer checks the GCP documentation and sees references to "Application Default Credentials" \(ADC\). They assume that because they ran \`gcloud auth login\` previously, the SDK should work, but they don't realize that \`gcloud auth login\` populates credentials for the \`gcloud\` CLI itself, not necessarily the ADC file that client libraries use. After examining the \`google-auth\` library source, they see the search order: env var, GCE metadata, gcloud ADC file. They check \`~/.config/gcloud/\` and see no \`application\_default\_credentials.json\`. Running \`gcloud auth application-default login\` creates this file, and the script works. Later, when containerizing the app, they forget to copy the ADC file or set the env var, hitting the same error. They realize that for production, they should mount a service account key or use Workload Identity, not rely on the gcloud-generated user credentials, as the latter are tied to a human user and expire.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T05:16:43.957765+00:00— report_created — created