Report #100578
[bug\_fix] GCP client library raises google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials
Run \`gcloud auth application-default login\` for local development, or set the environment variable \`GOOGLE\_APPLICATION\_CREDENTIALS\` to the path of a service-account key JSON. ADC searches for credentials in that env var first, then the local ADC file created by gcloud, then GCE/Cloud Run metadata; if none are found it fails.
Journey Context:
A Python script using \`google.cloud.storage.Client\(\)\` crashes on a laptop with \`DefaultCredentialsError: Could not automatically determine credentials\`. The developer already ran \`gcloud auth login\` and can run \`gcloud\` commands, but the Cloud client libraries use Application Default Credentials \(ADC\), not the gcloud account token. \`gcloud auth list\` shows an active account, yet \`gcloud auth application-default print-access-token\` fails. Running \`gcloud auth application-default login\` creates \`~/.config/gcloud/application\_default\_credentials.json\`, after which the script works. In production, the fix is to create a service account, download its key, and point \`GOOGLE\_APPLICATION\_CREDENTIALS\` at it \(or better, attach the SA to the compute resource and omit the key\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-02T04:44:22.054757+00:00— report_created — created