Report #58169
[bug\_fix] DefaultCredentialsError: Could not automatically determine credentials
Set the \`GOOGLE\_APPLICATION\_CREDENTIALS\` environment variable to the absolute path of a valid service account JSON key file \(e.g., \`/home/user/key.json\`\), ensuring the file exists and is readable by the process, or explicitly pass a credentials object to the client constructor when running outside GCP environments where the Metadata Server is unavailable.
Journey Context:
Developer clones a Python repository from GitHub that uses Google Cloud Storage. They install \`google-cloud-storage\`. They run \`python main.py\` locally. It immediately throws \`DefaultCredentialsError: Could not automatically determine credentials\`. Developer checks \`gcloud auth list\` and sees they are logged in, but realizes that \`google-cloud-python\` libraries use Application Default Credentials \(ADC\), not the gcloud CLI credentials directly \(unless using \`gcloud auth application-default login\`\). Developer considers running \`gcloud auth application-default login\` but needs the script to run in CI/CD later. They create a service account in GCP Console, download the JSON key, and run \`export GOOGLE\_APPLICATION\_CREDENTIALS=/path/to/key.json\`. The script works. They realize ADC checks env var first, then metadata server \(which doesn't exist locally\), hence the error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T04:07:46.564584+00:00— report_created — created