Could not load the default credentials? (Node.js Google Compute Engine tutorial)

Coder1000 picture Coder1000 · Feb 4, 2017 · Viewed 57.6k times · Source

SITUATION:

I follow this tutorial: https://cloud.google.com/nodejs/tutorials/bookshelf-on-compute-engine

Everything works fine until I do npm start and go to:

http://localhost:8080

I am met with the following text on the blank page:

Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information.

Which makes no sense since I am using OAuth. I followed the link and read the page, but I have no GOOGLE-APPLICATION-CREDENTIALS field anywhere, and nothing about it in the tutorial.


QUESTION:

Could you please reproduce the steps and tell me if you get the same result ?

(takes 5 minutes)

If not, what could I have done wrong ?

Answer

newbreedofgeek picture newbreedofgeek · Feb 6, 2017

Yes, I had the same error. It's annoying cause Google Cloud Platform docs for their "getting started" bookshelf tutorial does not mention this anywhere. Which means that any new developer who tries this tutorial will see this error.

Read this: https://developers.google.com/identity/protocols/application-default-credentials

I fixed this issue by running: gcloud auth application-default login

In order to run thisgcloud auth application-default login Visit: https://cloud.google.com/sdk/install 1) You have to install sdk into your computer 2) That will enable you to run the code 3) Log in to your associated gmail account then you are good to go!

This will make you login, and after that you code locally will use that authentication.