How to add phone and confirm sign up via phone otp and not with email otp
            Asked
            
        
        
            Active
            
        
            Viewed 967 times
        
    2 Answers
3
            
            
        try amazon_cognito_identity_dart package.
//Create a cognito user
CognitoUser cognitoUser1;
//Send OTP
 cognitoUser1 = CognitoUser(phoneNumber.text, widget.userPool);
  try {
    CognitoUserSession cognitoUserSession =
        await cognitoUser1.initiateAuth(
      AuthenticationDetails(
        authParameters: [
          AttributeArg(
            name: 'phone_number',
            value: phoneNumber.text,
          ),
        ],
      ),
    );
  } catch (cognitoUserCustomChallengeException) {}
  
//Authenticate the user
CognitoUserSession cognitoUserSession = await cognitoUser1.sendCustomChallengeAnswer(otp.text);
print("jwtToken " + cognitoUserSession.accessToken.jwtToken);
print("refreshToken " + cognitoUserSession.refreshToken.token);
        Chamod Dissanayake
        
- 641
 - 5
 - 13
 
0
            
            
        If I understand correctly, you're having some configuration issues with Cognito.
In order to enable the Phone OTP, you should connect to AWS, pick your project  and go to
User Pools > Attributes
and setup your configuration to use the Phone and/or email.
Then you have to go to
User Pools > MFA and verifications
and pick the phone number as the Attribute to verify.