简体   繁体   English

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

[英]Is possible use AWS Cognito with Node?

Im Using User Pool, and is possible develop a api to communicate with AWS Cognito?我正在使用用户池,是否可以开发一个 api 来与 AWS Cognito 通信? or just to communicate with front-end apps (android, ios, javascript web)?或者只是为了与前端应用程序(android、ios、javascript web)通信?

And if is possible, how can I identify the user logged and get their informations?如果可能的话,我如何识别登录的用户并获取他们的信息?

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

UPDATE 2 : Cognito is better to use on front-end, because you need store 'cognitoUser' object.更新 2 :Cognito 更适合在前端使用,因为您需要存储“cognitoUser”对象。 And the methods is using this object.方法正在使用这个对象。

UPDATE 3 : You can do the login on backend, and use the token to use API Gateway on AWS.更新 3 :您可以在后端登录,并使用令牌在 AWS 上使用 API 网关。 But the problem is if you need update something on Cognito.但问题是您是否需要在 Cognito 上更新某些内容。 If you need, you can use the admin methods ( https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/Welcome.html ).如果需要,您可以使用管理方法 ( https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/Welcome.html )。

Yes of course it's possible, here is a sample example to use cognito with facebook login on node: https://gist.github.com/pcoady/8afab5defb89f1900c9b是的,当然有可能,这是一个在节点上使用 cognito 和 facebook 登录的示例: https ://gist.github.com/pcoady/8afab5defb89f1900c9b

You can also check this step by step tutorial from backspace.academy (3 parts)您还可以从backspace.academy (3 个部分)查看此分步教程

From another stackoverflow answer :来自另一个stackoverflow 答案

The ID Token that you exchange with Cognito federated identity service to get the identity id and credentials already has all user attributes.您与 Cognito 联合身份服务交换以获取身份 ID 和凭证的 ID 令牌已经具有所有用户属性。 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.它是一个 JWT 令牌,您可以使用客户端上的任何库来解码这些值。 You can read this guide for more information about the tokens vended by Cognito user pools.您可以阅读本指南,了解有关 Cognito 用户池出售的令牌的更多信息。

Alternatively, you can also use the Access Token to call GetUser API which will return all the user information.或者,您也可以使用访问令牌调用GetUser API ,这将返回所有用户信息。

You can checkthis code to retrieve the cognito IDToken with nodejs您可以检查此代码以使用 nodejs 检索认知 IDToken

Im Using User Pool, and is possible develop a api to communicate with AWS Cognito?我正在使用用户池,是否可以开发一个 api 与 AWS Cognito 通信? or just to communicate with front-end apps (android, ios, javascript web)?还是只是为了与前端应用程序(android、ios、javascript web)进行通信?

And if is possible, how can I identify the user logged and get their informations?如果可能,我如何识别登录的用户并获取他们的信息?

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

UPDATE 2 : Cognito is better to use on front-end, because you need store 'cognitoUser' object.更新 2 :Cognito 最好在前端使用,因为您需要存储“cognitoUser”对象。 And the methods is using this object.方法正在使用这个对象。

UPDATE 3 : You can do the login on backend, and use the token to use API Gateway on AWS.更新 3 :您可以在后端进行登录,并使用令牌在 AWS 上使用 API 网关。 But the problem is if you need update something on Cognito.但问题是您是否需要在 Cognito 上更新某些内容。 If you need, you can use the admin methods ( https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/Welcome.html ).如果需要,您可以使用管理方法 ( https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/Welcome.html )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM