Project ID not automatically determined from key file
See original GitHub issueCopied 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
- OS: macOS 10.13.2
- Node.js version: 8.9.1
- npm version: 5.6.0
- @google-cloud/pubsub version: 0.16.0
Steps to reproduce
- Let
pubsub
be configured using onlykeyFilename
orGOOGLE_APPLICATION_CREDENTIALS
- 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:
- Created 6 years ago
- Reactions:1
- Comments:13 (7 by maintainers)
Top GitHub Comments
I believe I found a fix: #74
@victorandree would you mind trying again?
double checks for nodejs-storage instead of nodejs-pubsub… nope, we’re good 😃
@stephenplusplus Yes, it works! And I verified again that it does not work without this patch so I think you fixed it 😃