Flutter 注册确认通过电话 otp 在 aws 放大

时间:2021-01-11 10:38:48

标签: flutter aws-amplify amplify-flutter

如何通过电话 otp 而不是电子邮件 otp 添加电话和确认注册

2 个答案:

答案 0 :(得分:2)

试试 amazon_cognito_identity_dart 包。

//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);

答案 1 :(得分:0)

如果我理解正确,您在使用 Cognito 时遇到了一些配置问题。
为了启用电话 OTP,您应该连接到 AWS,选择您的项目并转到

<块引用>

用户池 > 属性

并设置您的配置以使用电话和/或电子邮件。
那你必须去

<块引用>

用户池 > MFA 和验证

并选择电话号码作为要验证的属性。