This repository was archived by the owner on Nov 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 409
This repository was archived by the owner on Nov 20, 2025. It is now read-only.
Requires projectId even when not used #755
Copy link
Copy link
Closed
Labels
type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
Description
Environment details
- OS: linux
- Node.js version: v10.15.3
- npm version: 6.4.1
google-auth-libraryversion: 5.0.0
Steps to reproduce
- Run
gcloud auth revoke(if needed) - Run
gcloud auth application-default login - run script
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 loginandgcloud auth application-default loginthen the script works
voncay, thelogotiprus, lukepereira, Stono, vitaliytv and 12 more
Metadata
Metadata
Assignees
Labels
type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.