简体   繁体   English

注销用户AWS Cognito

[英]signout user aws cognito

I have Integrated AWS SDK in Node.js. 我在Node.js中集成了AWS开发工具包。 I'm following this documentation to do some actions using the SDK. 我正在按照文档使用SDK进行一些操作。 However, I didn't find any method to sign out a user in that documentation. 但是,在该文档中我没有找到任何方法来注销用户。 We have GlobalSignOut and AdminUserGlobalSignOut . 我们有GlobalSignOutAdminUserGlobalSignOut But in my case, I want to sign out a user for a particular session only. 但就我而言,我只想针对特定会话注销用户。

I understand that you would want a particular session of a user in your Cognito User Pool to terminate, instead of terminating the sessions in all devices. 我了解您希望Cognito用户池中的特定用户会话终止,而不是终止所有设备中的会话。

To achieve this use-case, you can utilize the ForgetDevice[1] and AdminForgetDevice[2] API calls. 要实现此用例,可以利用ForgetDevice [1]和AdminForgetDevice [2] API调用。 These API calls make the refresh token associated with a device invalid, and as a result, the app will not be able to refresh new tokens and will force the user to sign-in successfully again. 这些API调用会使与设备关联的刷新令牌无效,因此,该应用将无法刷新新令牌,并将强制用户再次成功登录。

A code snippet of Cognito's AdminForgetDevice API call in JavaScript is as follows: JavaScript中Cognito的AdminForgetDevice API调用的代码段如下:

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
});

For a more detailed explanation on remembering devices in Amazon Cognito, kindly refer to the following AWS Mobile Blog post[3]. 有关在Amazon Cognito中记忆设备的更详细说明,请参考以下AWS Mobile Blog帖子[3]。

References 参考

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

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

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

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

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