I am trying to set up the development environment for a project that uses an API hosted in GCP. We are using the Google Auth Library: Node.js Client, and it tries to pull an ID token automatically, and fails. This is the error:
Error: Cannot fetch ID token in this environment, use GCE or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to a service account credentials JSON file.
So, I've solved this by manually downloading a service account key and pointing the GOOGLE_APPLICATION_CREDENTIALS
environment variable to it. However, when more developers start to work on this project, it would be great to have a somewhat more automatic or streamlined solution.
I've been reading around, and was hoping that setting the GOOGLE_APPLICATION_CREDENTIALS
to the key file generated by gcloud auth application-default login
would do the trick. But, it seems like the library doesn't work with user credentials? At least it doesn't work when I try it.
Having a way where the developer setting up the project in development would either simply authenticate with Google in the terminal, or point the GOOGLE_APPLICATION_CREDENTIALS
to a file generated by a gcloud
command would be great, instead of having the person go into GCP to download a service account key.
Is this possible somehow? It's been a little tricky to find out. Thanks!
Some other questions I've seen: