question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Project ID not automatically determined from key file

See original GitHub issue
Copied from original issue: https://github.com/GoogleCloudPlatform/google-cloud-node/issues/2782

@victorandree
December 21, 2017 8:30 AM

Pub/Sub authentication documentation suggests that the project ID will be determined automatically if you provide a keyFilename or GOOGLE_APPLICATION_CREDENTIALS

If you wish, you can set an environment variable (GCLOUD_PROJECT) in place of specifying this inline. Or, if you have provided a service account JSON key file as the config.keyFilename property explained above, your project ID will be detected automatically.

Source: https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.15.0/guides/authentication

I can’t get the “your project ID will be detected automatically” bit to work, and still need to provide projectId expressly (either as GCLOUD_PROJECT env variable or to the configuration call). This feature isn’t really mentioned anywhere else, so maybe it’s unsupported? Seems like a good idea though!

This may be related to this issue: https://github.com/GoogleCloudPlatform/google-cloud-node/issues/2576

Environment details

Steps to reproduce

  1. Let pubsub be configured using only keyFilename or GOOGLE_APPLICATION_CREDENTIALS
  2. Try to subscribe to some topic

Sample code:

const pubsub = require('@google-cloud/pubsub')();

const subscription = pubsub.subscription('test-subscription');
subscription.on('message', message => {
  console.log('message received');
  message.ack();
});

Error message:

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: Requested project not found or user does not have access to it (project={{projectId}}). Make sure to specify the unique project identifier and not the Google Cloud Console display name.
    at StreamProxy.onConnectionStatus (/code/pubsub/node_modules/@google-cloud/pubsub/src/connection-pool.js:264:21)
    at emitOne (events.js:116:13)
    at StreamProxy.emit (events.js:211:7)
    at ClientDuplexStream.<anonymous> (/code/pubsub/node_modules/google-gax/lib/streaming.js:130:17)
    at emitOne (events.js:116:13)
    at ClientDuplexStream.emit (events.js:211:7)
    at ClientDuplexStream._emitStatusIfDone (/code/pubsub/node_modules/grpc/src/client.js:260:10)
    at ClientDuplexStream._receiveStatus (/code/pubsub/node_modules/grpc/src/client.js:233:8)
    at /code/pubsub/node_modules/grpc/src/client.js:757:12

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
stephenpluspluscommented, Feb 20, 2018

I believe I found a fix: #74

@victorandree would you mind trying again?

$ npm install --save git+https://github.com/stephenplusplus/nodejs-pubsub.git#spp--23

double checks for nodejs-storage instead of nodejs-pubsub… nope, we’re good 😃

0reactions
victorandreecommented, Feb 20, 2018

@stephenplusplus Yes, it works! And I verified again that it does not work without this patch so I think you fixed it 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Project ID not automatically determined from key file #2782
I can't get the "your project ID will be detected automatically" bit to work, and still need to provide projectId expressly (either as ......
Read more >
firebase cannot determine project id - node.js
In the Firebase console, open Settings > Service Accounts. Click Generate New Private Key, then confirm by clicking Generate Key. Securely store ...
Read more >
Creating and managing projects - Documentation
Project number: An automatically generated unique identifier for your project. Don't include sensitive information in your project name, project ID, ...
Read more >
google-auth 1.14.2 documentation
Implements application default credentials and project ID detection. ... _HELP_MESSAGE = """\ Could not automatically determine credentials.
Read more >
Projects
Cypress uses your projectId and Record Key together to uniquely identify ... your project and automatically insert it into your Cypress configuration file....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found