AWS Cognito - MFA setup



我使用JavaScript AWS SDK进行MFA设置,有两个问题:首先,我使用updateUserAttributes方法更新电话号码(phone_number属性(。

它更新但返回空对象,而不是(根据文档(:

{
"CodeDeliveryDetailsList": [ 
{ 
"AttributeName": "string",
"DeliveryMedium": "string",
"Destination": "string"
}
]
}

其次,我试图向用户发送一个带有getAttributeVerificationCode的验证码,该验证码具有以下有效载荷:

const params = { 
AccessToken: auth.accessToken,    
AttributeName: 'phone_number'
}

我得到

CustomMessage failed with error
Cannot read property identity of undefined

作为错误。有什么想法吗?

对于遇到相同问题的用户,我们可以使用cognitoUser.updateAttributes来解决问题,而不是使用与官方文档相反的cognitoentityserviceprovider.updateUserAttributes。AWS,尤其是cognito还为时过早,对于那些正在考虑使用的人来说,缺乏文档是另一个问题。

AWS需要字符串,可能这里传递的令牌不正确。。。

const params =    {
"AccessToken": auth.accessToken.toString(),
"UserAttributes": [ 
{ 
"Name": "phone number",
"Value": "(555)555-5555"
}
]
}

在这里。。。

const params = {
"AccessToken": auth.accessToken.toString(),
"AttributeName": "phone number"
}

最新更新