Report #103464
[bug\_fix] Google Cloud client libraries or gcloud raise 'google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials.'
Run \`gcloud auth application-default login\` to create or refresh the local Application Default Credentials file at \`~/.config/gcloud/application\_default\_credentials.json\`. In production, remove this dependency and instead attach a service account to the compute resource or set \`GOOGLE\_APPLICATION\_CREDENTIALS\` to a workload-identity configuration file.
Journey Context:
You clone a repo that uses the Python \`google-cloud-storage\` client. On the first run it throws \`DefaultCredentialsError: Could not automatically determine credentials\`. You set \`GOOGLE\_APPLICATION\_CREDENTIALS\` to an old service-account key you found in the repo, and it works locally, but CI fails because that path does not exist there. You then read the error carefully: ADC searches \(1\) \`GOOGLE\_APPLICATION\_CREDENTIALS\`, \(2\) the well-known file created by \`gcloud auth application-default login\`, and \(3\) the metadata server for an attached service account. Your local machine has none of these, and the old key is a bad practice anyway. You run \`gcloud auth application-default login --project=my-project\`, authenticate in the browser, and the library starts working because ADC now finds \`~/.config/gcloud/application\_default\_credentials.json\`. For the production deployment you switch to a service account attached to the Cloud Run service, so ADC falls through to the metadata server and no JSON key is shipped.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-11T04:26:26.686146+00:00— report_created — created