Report #97783
[bug\_fix] Google Cloud SDK: Could not automatically determine credentials / Application Default Credentials failed
Run \`gcloud auth application-default login\` to create local ADC credentials, or set \`GOOGLE\_APPLICATION\_CREDENTIALS\` to a valid service-account key or config file. In production on GCP, attach a service account to the compute resource and grant it the required IAM roles.
Journey Context:
You run a Python script locally that uses \`google-cloud-storage\` and it fails with \`DefaultCredentialsError: Could not automatically determine credentials\`. You have \`gcloud\` installed and can run \`gcloud projects list\`, so your gcloud credentials are fine, but ADC is a separate credential store used by client libraries. ADC looks first at \`GOOGLE\_APPLICATION\_CREDENTIALS\`, then at \`~/.config/gcloud/application\_default\_credentials.json\`, then at the metadata server. On a local machine there is no metadata server, and the ADC file was never created. Running \`gcloud auth application-default login\` creates that file with your user credentials. In GKE, Cloud Run, or Compute Engine, the fix is to attach a service account to the resource and grant it IAM roles, because ADC will then fetch tokens from the metadata server. The docs explicitly state that attached service accounts are the preferred production method.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-26T04:41:55.670318+00:00— report_created — created