gpt4 book ai didi

node.js - 可以将 AWS Cognito 与 Node 一起使用吗?

转载 作者:太空宇宙 更新时间:2023-11-04 00:08:59 26 4
gpt4 key购买 nike

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

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

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

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

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

最佳答案

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

您还可以从backspace.academy查看此分步教程。 (3部分)

来自另一个stackoverflow answer :

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

关于node.js - 可以将 AWS Cognito 与 Node 一起使用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50868382/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com