AWS Cognito - 无需 MFA 验证电话号码

时间:2021-01-29 13:32:03

标签: amazon-web-services amazon-cognito

我开始使用(试验)AWS Cognito,被它承诺让用户注册简单所吸引。到目前为止,我比预期的更沮丧。

我的场景相当简单:

  • 使用电子邮件作为用户名的用户注册。还有电话号码是 提供和强制。

  • 用户必须验证电子邮件(Cognito 发送验证链接),然后用户在 认知。

到目前为止一切都很好...

然而,我的用例强制要求在用户可以在应用中进行任何进一步操作之前(使用 OTP)确认电话号码。

我的(远非完美)代码是:

var user = await _userManager.FindByIdAsync(login.Email);
var signInResult = await _signinManager.PasswordSignInAsync(user, login.Password, false, false);

if (!await _userManager.IsPhoneNumberConfirmedAsync(user))
{
    var sendPhoneConfirmationResult = await _userManager.SendPhoneConfirmationTokenAsync(user); // this returns an error
}

错误是:

Failed to get the Cognito User attribute verification code : Invalid phone number provided/Unable to send the message. User pool does not have SMS configuration to send messages.

我已确保用户的电话号码有效(以 + 开头,然后是 country code,然后是 9 digits)。我还可以从 AWS 发送测试短信。我还在用户池 -> 常规设置 -> MFA 和验证下创建了 SMS 角色(在部分“您必须提供一个角色以允许 Amazon Cognito 发送 SMS 消息”

知道我做错了什么,或者我对 Cognito 本身有什么误解吗?

0 个答案:

没有答案