确认 phone 更改了 Amazon Cognito 中的代码

Confirm phone changed code in Amazon Cognito

我在 Cognito 中有一个确认用户,我正在使用 AminUpdateUserAttributes 更改 phone 号码。此操作会触发发送到新 phone 号码的确认码以对其进行验证。问题是我在 API reference 中找不到用于确认此代码的方法。尝试 confirmSignUp 会引发此异常:

"error_message": "Invalid code provided, please request a code again. (Service: AWSCognitoIdentityProvider; Status Code: 400; Error Code: ExpiredCodeException; Request ID: 98dd9ed0-f96b-4e24-ab19-f3258e1c1e4e; Proxy: null)",

我认为这是因为用户没有注册,而是更改了他们的 phone 号码。那么,使用发送的代码确认 phone 号码属性更改的方式是什么?

深入搜索后,我在 aws doc 中找到了这个方法,它解决了我的问题:

VerifyUserAttribute

验证用户池中指定的用户属性。

请求语法

{
   "AccessToken": "string",
   "AttributeName": "string",
   "Code": "string"
}

所以我对此进行了测试并成功验证了用户的 phone 更改,正如 Cognito 仪表板用户的描述中所指出的那样: