【问题标题】:AWS Cognito - MFA setupAWS Cognito - MFA 设置
【发布时间】:2018-08-06 09:25:48
【问题描述】:

我使用 JavaScript AWS 开发工具包进行 MFA 设置,但有 2 个问题: 首先,我更新电话号码(使用 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

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

【问题讨论】:

    标签: amazon-web-services amazon-cognito multi-factor-authentication


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

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

      这里……

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-11-02
        • 2021-08-29
        • 2019-01-31
        • 1970-01-01
        • 2022-06-22
        • 1970-01-01
        • 2019-04-05
        • 2018-11-13
        相关资源
        最近更新 更多