[英]How do you use AWS Cognito with a custom NodeJS server?
I am building an app using Angular and NodeJS. 我正在使用Angular和NodeJS构建应用程序。
I've heard about AWS Cognito and would like to use it in my app. 我听说过AWS Cognito,并希望在我的应用程序中使用它。 However it is very unclear in the documentation how it is supposed to work.
但是,在文档中尚不清楚它应该如何工作。
There is an example on how to use Cognito with an Angular SPA, but there is no word on how I can use it to authenticate users on my backened NodeJS server. 有一个关于如何在Angular SPA中使用Cognito 的示例 ,但是没有关于如何使用它来对我的备份NodeJS服务器上的用户进行身份验证的消息。
How is NodeJS supposed to know if a user is logged in? NodeJS应该如何知道用户是否已登录? I can think of several possible answers, but none appear in the documentation and there is surprisingly no code sample.
我可以想到几个可能的答案,但是没有答案出现在文档中,而且令人惊讶的是没有代码示例。 So I decided to ask here before investing a lot of time in trial and error.
因此,我决定在投入大量时间进行反复试验之前先在这里询问。
You can use AWS Cognito Userpools in your backend NodeJS server to authenticate users. 您可以在后端NodeJS服务器中使用AWS Cognito Userpools对用户进行身份验证。 The steps are as follows.
步骤如下。
Note: Since the id_token is a standard JavaScript Web Token (JWT) you can find a library to validate it. 注意:由于id_token是标准的JavaScript Web令牌(JWT),因此您可以找到一个库对其进行验证。 Refer AWS documentation Using Tokens with User Pools for more details.
有关更多详细信息,请参阅AWS文档将令牌与用户池一起使用 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.