Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Cognito - MFA setup

I use the JavaScript AWS SDK for MFA setup and have 2 issues: First, I update phone number (phone_number attribute with updateUserAttributes method).

It updates but returns empty object instead of (according to docs):

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

Second, I am trying to send user a verification code with getAttributeVerificationCode with the following payload:

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

and I am getting

CustomMessage failed with error
Cannot read property identity of undefined

as error. Any ideas?

like image 812
Ugur Avatar asked Aug 06 '18 09:08

Ugur


People also ask

How do I disable MFA in Cognito?

Configuring multi-factor authentication. You can configure MFA in the Amazon Cognito console. From the left navigation bar, choose MFA and verifications. Choose whether MFA is Off, Optional, or Required.

What is TOTP in Cognito?

Configuring TOTP for your user is a multi-step process where your user receives a secret code that they validate by entering a one-time password. Next, you can enable TOTP MFA for your user or set TOTP as the preferred MFA method for your user.


1 Answers

For the ones who come across same problem, we could solve it by using cognitoUser.updateAttributes instead of cognitoidentityserviceprovider.updateUserAttributes contrary to the official docs. AWS, especially cognito is premature and lack of docs is another issue for the ones who are considering to use.

like image 173
Ugur Avatar answered Nov 10 '22 09:11

Ugur