You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 20, 2025. It is now read-only.
When I test/run code locally using auth.getIdTokenClient("https://my-target-audience") will always yield the error below, despite setting application default credentials using gcloud auth application-default login. Other google libs are working fine using this.
Cannot fetch ID token in this environment, use GCE or set the GOOGLE_APPLICATION_CREDENTIALS environment variable t o a service account credentials JSON file.
Is this a client library issue or a product issue?
A client library issue.
Did someone already solve this?
No
Do you have a support contract?
No
Environment details
OS: MacOS
Node.js version: 18.14.0
npm version: 9.3.1
google-auth-library version: 8.7.0
Steps to reproduce
Grant credentials with a privileged account using gcloud auth application-default login
Execute the following code from somewhere in your codebase in an async function
const auth = new GoogleAuth();
await auth.getIdTokenClient(this.analysisBaseUrl)
console.log("All good");
💥 - the following error is shown and the console log does not execute
Cannot fetch ID token in this environment, use GCE or set the GOOGLE_APPLICATION_CREDENTIALS environment variable t o a service account credentials JSON file.
If you export a JSON key and provide it via the environment variable GOOGLE_APPLICATION_CREDENTIALS then it will work. The other google libs, however, negate the need for this by supporting the application-default login and thus not needing privileged service account JSON keys stored locally.