确认本地moto服务器是否已经启动,并且端口号是否正确。
确认boto3中cognito-idp的配置是否正确,包括Region、AccessKey、SecretKey等信息。
示例代码:
import boto3
from botocore.config import Config
from botocore.exceptions import ClientError
from awscli.customizations import configure
config = Config(region_name='us-east-1')
client = boto3.client('cognito-idp', config=config, aws_access_key_id='YOUR_ACCESS_KEY',
aws_secret_access_key='YOUR_SECRET_KEY')
try:
response = client.admin_get_user(
UserPoolId='YOUR_USER_POOL_ID',
Username='USERNAME'
)
print(response)
except ClientError as e:
print(e)