此问题可能是由于用户池中的用户未确认电子邮件或电话号码而引起的。
以下是确认电子邮件示例:
import boto3
client = boto3.client('cognito-idp')
username = 'example_user'
client.admin_update_user_attributes(
UserPoolId='your-user-pool-id',
Username=username,
UserAttributes=[
{
'Name': 'email_verified',
'Value': 'True'
},
{
'Name': 'email',
'Value': 'example@example.com'
}
]
)
如果您的用户需要通过电话号码验证,请将电子邮件改为电话号码。
import boto3
client = boto3.client('cognito-idp')
username = 'example_user'
client.admin_update_user_attributes(
UserPoolId='your-user-pool-id',
Username=username,
UserAttributes=[
{
'Name': 'phone_number_verified',
'Value': 'True'
},
{
'Name': 'phone_number',
'Value': '+1234567890'
}
]
)
确保更新了所有必要的属性并使用正确的名称。