1
votes

How do I access an API hosted behind the google endpoint (ESP) from a Node JS client?. The Node JS client is running in a google compute Engine. I am trying to use Google ID token as mentioned in the below URL, but couldn't find a sample code for the same.

https://cloud.google.com/endpoints/docs/openapi/service-account-authentication#using_a_google_id_token

1

1 Answers

1
votes

Google has an official nodejs authentication library here:

https://github.com/google/google-auth-library-nodejs

If you're looking for code samples for how to authenticate to a remote service using a Google Web Token, there are several complete examples for different environments in that repository's README file, including an example for running in GCP:

https://github.com/google/google-auth-library-nodejs#json-web-tokens