从node.js应用程序调用Google端点框架 [英] Call google endpoint frameworks from node.js application

查看:127
本文介绍了从node.js应用程序调用Google端点框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从我的node.js应用程序中调用使用Google云端点框架创建的API.我如何才能完成身份验证过程并调用上述API?是否可以从node.js应用程序访问API?

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?

推荐答案

根据官方文档,Cloud Endpoints Framework是适用于App Engine标准(仅限)Python 2.7和Java 8运行时环境的Web框架.它不支持Node.js(也不是PHP,Go)运行时环境.

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.

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

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

您最初的问题(是否可以从node.js应用程序访问API")的答案是.

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

您的客户端应用程序不需要使用Python或Java,它可以使用任何语言,例如Node.js.

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

关于身份验证,对于后端应用程序(GAE),流程如下:

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

  1. 您可以通过在Google Cloud Platform上创建服务帐户.

API装饰器中,然后添加服务帐户和公共证书链接.

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

在API Decorator中,也将SA添加为受众.

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

最后,在您的Node.js应用程序(客户端)上,通过请求JWT令牌来请求身份验证:

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

1.在API Decorator上创建具有相同受众群体的 JWT ,并使用服务帐户的私钥.

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.在请求中向API发送已签名的JWT.

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

下面有一些呼叫请求的示例.我没有在Node.js中找到示例,它们在Python中,但是您可以将它们转换为Node.js,因为流程基本相同:

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身份验证请求GCP官方文档.

2.访问需要身份验证的API(Python客户端)

3.Github Google-Client-JWT示例.

这篇关于从node.js应用程序调用Google端点框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆