【发布时间】:2020-11-04 11:14:51
【问题描述】:
我在我的 Python Lambda 函数中使用 AWS sdk 来获取 Cognito 用户的属性。喜欢这段代码:
client = boto3.client('cognito-idp')
try:
response = client.admin_get_user(
UserPoolId=pool_id,
Username=email
)
if response is not None and 'Username' in response and 'UserAttributes' in response:
res = response['UserAttributes']
return res
else:
return None
except ClientError as e:
if e.response['Error']['Code'] == 'UserNotFoundException':
print("USER NOT FOUND")
return None
raise e
return None
当我尝试使用 AdminGetUser API 获取多个用户(大约 50 个用户)时,我收到了 TooManyRequestsException 错误。
根据 AWS Doc,每秒从 Cognito 获取用户信息的默认限制是多少?我看到这个页面Quotas in Amazon Cognito 但我看不到这个默认限制是什么。
处理这个问题的最佳方法是什么?
现在我打算等待 1 秒钟,然后我会尝试从同一个用户那里获取用户的属性,同时我得到相同的异常。
谢谢!
【问题讨论】:
标签: python amazon-web-services aws-lambda amazon-cognito aws-serverless