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
const {GoogleAuth} = require('google-auth-library')
async function run () {
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/cloud-platform'
});
client = await auth.getClient();
console.info(client)
}
run();
Get error
Error: Unable to detect a Project Id in the current environment.
To learn more about authentication and Google APIs, visit: https://cloud.google.com/docs/authentication/getting-started
at _getDefaultProjectIdPromise.Promise (/usr/local/google/home/kaylanguyen/Downloads/buildartifacts-npm-tools/node_modules/google-auth-library/build/src/auth/googleauth.js:90:31)
at process._tickCallback (internal/process/next_tick.js:68:7)
Expectation:
Able to create a client and get an access token without having to clarify projectID because I don't need it.
Work around:
Have a fake projectId
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/cloud-platform',
projectId: 'fake-project'
});
Other gotchas:
export GOOGLE_APPLICATION_CREDENTIALS=<path/to/service/account> works
Runing both gcloud auth login and gcloud auth application-default login then the script works
The text was updated successfully, but these errors were encountered:
Environment details
google-auth-library
version: 5.0.0Steps to reproduce
gcloud auth revoke
(if needed)gcloud auth application-default login
Error: Unable to detect a Project Id in the current environment.
To learn more about authentication and Google APIs, visit:
https://cloud.google.com/docs/authentication/getting-started
at _getDefaultProjectIdPromise.Promise (/usr/local/google/home/kaylanguyen/Downloads/buildartifacts-npm-tools/node_modules/google-auth-library/build/src/auth/googleauth.js:90:31)
at process._tickCallback (internal/process/next_tick.js:68:7)
Expectation:
Work around:
Other gotchas:
gcloud auth login
andgcloud auth application-default login
then the script worksThe text was updated successfully, but these errors were encountered: