6

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

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

{
    "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

作为错误。有任何想法吗?

4

2 回答 2

3

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

于 2018-08-22T09:15:06.857 回答
0

AWS 期待字符串,也许令牌在这里传递不正确......

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

和这里...

const params = {
   "AccessToken": auth.accessToken.toString(),
   "AttributeName": "phone number"
}
于 2018-08-17T15:59:26.750 回答