Report #81620
[bug\_fix] google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials
Run \`gcloud auth application-default login\` to populate the well-known ADC location \(~/.config/gcloud/application\_default\_credentials.json on Linux/macOS\), or set GOOGLE\_APPLICATION\_CREDENTIALS to a valid service account JSON only for non-interactive environments. This creates an OAuth2 user credential that the ADC chain discovers via the gcloud metadata.
Journey Context:
Developer clones a Python repository using the Google Cloud SDK and attempts to run a script accessing BigQuery. Immediately hits DefaultCredentialsError. Checks environment variables and finds GOOGLE\_APPLICATION\_CREDENTIALS is unset. Downloads a service account JSON key from the console, exports the path, and the script works, but the security team flags the long-lived key as a risk. Digging into the ADC documentation, the developer realizes that \`gcloud auth application-default login\` creates a local credential file at the well-known path that the Google Auth library searches automatically. After running the command and authenticating via browser, the script works without the env var, using the user’s identity with the same quota and billing as the service account would have.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T19:36:01.179469+00:00— report_created — created