Report #7063
[bug\_fix] GCP Application Default Credentials \(ADC\) not found: DefaultCredentialsError
For local development, run \`gcloud auth application-default login\` to generate the \`application\_default\_credentials.json\` file in \`~/.config/gcloud/\`. This command opens a browser to authenticate your user account and stores the OAuth2 refresh token for use by client libraries. For production environments \(GCE, Cloud Run, GKE with Workload Identity\), ensure the environment supports the metadata server \(\`169.254.169.254\`\) and that the service account attached to the resource has the necessary permissions; the SDK will automatically query the metadata server for an access token, so no env var is needed. If you must use a service account key file \(not recommended\), download the JSON key and set \`export GOOGLE\_APPLICATION\_CREDENTIALS="/path/to/key.json"\`, but prefer \`gcloud auth application-default login\` for local development to avoid key file sprawl.
Journey Context:
A developer clones a Python repository containing a data pipeline that uses \`google.cloud.bigquery.Client\(\)\`. They have Google Cloud SDK installed and have previously run \`gcloud auth login\` to set their user account for CLI commands like \`gsutil\`. They execute \`python pipeline.py\` and it immediately raises \`google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials\`. The developer checks \`gcloud config list account\` and sees their email is set, causing confusion. They search the error and learn that \`gcloud auth login\` sets credentials for the CLI only, while client libraries use Application Default Credentials \(ADC\). They run \`gcloud auth application-default login\`, which opens a browser, they select their Google account, and the command writes \`~/.config/gcloud/application\_default\_credentials.json\`. They re-run \`python pipeline.py\` and the BigQuery client successfully initializes using the ADC OAuth2 token.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T01:43:38.959161+00:00— report_created — created