Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requires projectId even when not used #755

Closed
KaylaNguyen opened this issue Jul 24, 2019 · 0 comments · Fixed by #1448
Closed

Requires projectId even when not used #755

KaylaNguyen opened this issue Jul 24, 2019 · 0 comments · Fixed by #1448
Assignees
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@KaylaNguyen
Copy link

Environment details

  • OS: linux
  • Node.js version: v10.15.3
  • npm version: 6.4.1
  • google-auth-library version: 5.0.0

Steps to reproduce

  1. Run gcloud auth revoke (if needed)
  2. Run gcloud auth application-default login
  3. 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();
  1. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants