【问题标题】:signout user aws cognito注销用户 aws cognito
【发布时间】:2019-04-12 16:40:03
【问题描述】:

我在 Node.js 中集成了 AWS 开发工具包。我正在关注this 文档以使用 SDK 执行一些操作。但是,我没有在该文档中找到任何注销用户的方法。我们有GlobalSignOutAdminUserGlobalSignOut。但就我而言,我只想让用户退出特定会话。

【问题讨论】:

  • 您找到解决方案了吗?

标签: node.js amazon-web-services aws-sdk amazon-cognito


【解决方案1】:

我了解您希望终止 Cognito 用户池中用户的特定会话,而不是终止所有设备中的会话。

要实现此用例,您可以利用 ForgetDevice[1] 和 AdminForgetDevice[2] API 调用。这些 API 调用使与设备关联的刷新令牌无效,因此,应用将无法刷新新令牌并强制用户再次成功登录。

Cognito 的 AdminForgetDevice API 在 JavaScript 中调用的代码 sn-p 如下:

var params = {
  DeviceKey: 'STRING_VALUE', /* required */
  UserPoolId: 'STRING_VALUE', /* required */
  Username: 'STRING_VALUE' /* required */
};
cognitoidentityserviceprovider.adminForgetDevice(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

有关在 Amazon Cognito 中记住设备的更详细说明,请参阅以下 AWS 移动博客文章 [3]。

参考文献

[1]。 https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ForgetDevice.html

[2]。 https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminForgetDevice.html

[3]。 https://aws.amazon.com/blogs/mobile/tracking-and-remembering-devices-using-amazon-cognito-your-user-pools/

【讨论】:

  • 在当前的 aws sdk 启动方法 (docs.aws.amazon.com/cognito-user-identity-pools/latest/…) 响应元素具有 devicekey。但是当我运行应用程序时,它返回一个空值。因此我无法使用管理员忘记设备方法在我的注销请求中发送它。你能帮我解决这个问题吗?谢谢。
猜你喜欢
  • 2019-04-24
  • 2018-11-28
  • 2019-04-06
  • 2022-11-27
  • 2019-12-25
  • 1970-01-01
  • 2017-12-27
  • 2018-09-21
  • 2022-12-10
相关资源
最近更新 更多