首页 > 解决方案 > 在 AWS Cognito 中重新发送 phone_number 属性验证码

问题描述

AWS SDK CognitoIdentityServiceProvider中是否有办法为CONFIRMED用户重新发送 phone_number 属性更改验证码?

我已在Cognito中设置要验证的 phone_number 属性。adminUpdateUserAttributes()发送验证码。但是我没有找到重新发送验证码的方法。这是我正在处理的用例中的必要条件。

到目前为止,我已经尝试过adminUpdateUserAttributes()使用相同的电话号码。它似乎没有重新发送验证码。有了新号码,就可以了。

我无法deleteUserAttributes()再次进行更新,因为池配置会根据需要设置电话号码。

不确定它是否相关;但请注意,我几乎必须使用CognitoIdentityServiceProvider管理 API,因为在用户池中也禁用了 Sign UP。

总而言之,我正在寻找一种解决方案,我可以在 Cognito 用户池中的已确认用户中重新发送 phone_number 属性的验证码。

标签: amazon-web-servicesamazon-cognito

解决方案


这是 AWS Api 参考中为该流程重新发送 OTP 代码的方法: https ://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetUserAttributeVerificationCode.html

然后在我的服务中,使用 AWS Java SDK,我称之为:

    public void resendCodeAttributeVerification(String accessToken) {
    cognitoClient.getUserAttributeVerificationCode(new GetUserAttributeVerificationCodeRequest()
            .withAttributeName(PHONE_NUMBER)
            .withAccessToken(accessToken));
     }

推荐阅读