可以将 AWS Cognito 与 Node 一起使用吗?

Is possible use AWS Cognito with Node?

我正在使用用户池,是否可以开发一个 api 来与 AWS Cognito 通信?或者只是为了与前端应用程序(android、ios、javascript 网络)通信?

如果可能的话,我如何识别登录的用户并获取他们的信息?

更新 1: 获取解码 jwt 信息:https://github.com/awslabs/aws-support-tools/tree/master/Cognito/decode-verify-jwt

更新 2: Cognito 更适合在前端使用,因为您需要存储 'cognitoUser' 对象。并且方法正在使用这个对象。

更新 3: 您可以在后端进行登录,并使用令牌在 AWS 上使用 API 网关。但问题是您是否需要在 Cognito 上更新某些内容。如果需要,可以使用管理方法(https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/Welcome.html)。

当然可以,这是一个在节点上使用 cognito 和 facebook 登录的示例:https://gist.github.com/pcoady/8afab5defb89f1900c9b

您还可以从 backspace.academy(3 个部分)

查看此分步教程

来自另一个 :

The ID Token that you exchange with Cognito federated identity service to get the identity id and credentials already has all user attributes. You do not need an extra call to any service.

It is a JWT token and you can use any library on the client to decode the values. You can read this guide for more information about the tokens vended by Cognito user pools.

Alternatively, you can also use the Access Token to call GetUser API which will return all the user information.

您可以检查 this code 以使用 nodejs 检索 cognito IDToken