这个问题可能是由于客户端SDK v3中Admin disable user命令的参数格式发生了变化。为了解决这个问题,您可以尝试将参数对象中的'password”属性更改为'Password”,并确保'Password”属性是通过下划线分隔的字符串格式。
示例代码如下所示:
// Create a new instance of the AdminUserPoolClient
const cognito = new CognitoUserPoolClient({
region: 'your-region',
userPoolId: 'your-user-pool-id',
clientId: 'your-client-id',
credentials: {
accessKeyId: 'your-access-key-id',
secretAccessKey: 'your-secret-access-key',
},
});
// Disable user
const username = 'user@example.com';
const params = {
UserPoolId: 'your-user-pool-id',
Username: username,
Password: '_',
};
cognito.send(new AdminDisableUserCommand(params)).then((result) => console.log(result));
通过上面更改后的代码,您应该可以成功地使用AWS Cognito客户端SDK v3运行管理员禁用用户命令了。