Report #42395
[bug\_fix] GCP ADC Error: Could not load the default credentials
Run \`gcloud auth application-default login\` to generate user credentials in \`~/.config/gcloud/application\_default\_credentials.json\`, or set the \`GOOGLE\_APPLICATION\_CREDENTIALS\` environment variable to the absolute path of a valid service account JSON key file. Root cause: Application Default Credentials \(ADC\) searches a specific hierarchy: env var, GAE/GCE metadata server, local gcloud ADC file. If none provide a valid token, the SDK throws this error. This commonly occurs in new development environments or when the key file path is wrong.
Journey Context:
You clone a Python repository that uses BigQuery. You install the requirements and run \`python main.py\`. It immediately crashes with \`google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials\`. You check the README—it says 'Set up GCP credentials'. You look at your environment variables—\`GOOGLE\_APPLICATION\_CREDENTIALS\` is unset. You have a service account key file \`key.json\` in your downloads. You run \`export GOOGLE\_APPLICATION\_CREDENTIALS=~/Downloads/key.json\` and run again. Same error. You check the path—it's correct. You \`cat\` the file—it contains valid JSON. You realize the file permissions might be wrong, but more likely, you copied the path incorrectly. Actually, you used a relative path in the export but ran the script from a different directory. You use the absolute path \`/home/user/Downloads/key.json\` and it works. Alternatively, you decide not to use a key file and run \`gcloud auth application-default login\`, authenticate via browser, and the script works using your user credentials.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T01:37:49.912932+00:00— report_created — created