Call google endpoint frameworks from node.js application

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-25 07:04:55

问题


I need to call API's created using google cloud endpoint framework from my node.js applications. How I will be able to complete auth process and call the above APIs? Is it possible from node.js application to access the API's?


回答1:


According to the official documentation, Cloud Endpoints Framework is a web framework for the App Engine standard (only) Python 2.7 and Java 8 runtime environments. It doesn’t support Node.js (nor PHP, Go) runtime environments.

=========================================================================

EDIT:

The answer to your initial question (“Is it possible from node.js application to access the API's”) is yes.

Your client application does not need to be in Python or Java, it can be on any language such as Node.js.

Regarding authentication, for the backend app (GAE), the flow would be the following:

  1. You can authenticate the access to the Endpoints by creating a Service Account on Google Cloud Platform.

  2. In the API Decorator, add the Service Account and public cert link.

  3. In the API Decorator, add the SA as audience also.

Finally, on your Node.js application (client side), request Authentication by requesting the JWT token:

1.Create a JWT with the same audience set before on the API Decorator and sign it with the service account's private key.

2.Send the signed JWT in a request to the API.

Below you have some examples of the call request. I didn’t find examples in Node.js, they are in Python, but you can translate them to Node.js since the flow is basically the same:

1.JWT Authentication request GCP official documentation.

2.Accessing an API requiring Authentication (Python Client)

3.Github Google-Client-JWT Sample.



来源:https://stackoverflow.com/questions/58638095/call-google-endpoint-frameworks-from-node-js-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!