【发布时间】:2018-05-30 16:31:28
【问题描述】:
我已经被以下问题困扰了很长一段时间了。在 Python 中,我希望用户使用 srp 身份验证从 AWS cognito-identity-pool 中根据他们的用户名和密码检索令牌。有了这个令牌,我希望用户将数据上传到 s3。
这是我使用的代码的一部分(来自授权库):https://github.com/capless/warrant
self.client = boto3.client('cognito-idp', region_name="us-east-1")
response = boto_client.initiate_auth(
AuthFlow='USER_SRP_AUTH',
AuthParameters=auth_params,
ClientId=self.client_id
)
def get_auth_params(self):
auth_params = {'USERNAME': self.username,
'SRP_A': long_to_hex(self.large_a_value)}
if self.client_secret is not None:
auth_params.update({
"SECRET_HASH":
self.get_secret_hash(self.username,self.client_id, self.client_secret)})
return auth_params
但是,我不断得到:
botocore\auth.py", line 352, in add_auth raise NoCredentialsError
botocore.exceptions.NoCredentialsError: Unable to locate credentials
我可以通过在 .aws/credentials 文件中添加凭据来消除此错误。但这不符合本计划的宗旨。授权或 botocore 库中似乎存在错误,它继续尝试使用凭证文件中的 AWS 访问密钥 ID 和 AWS 秘密访问密钥,而不是使用给定的凭证(用户名和密码)。
感谢任何帮助
【问题讨论】:
标签: python amazon-web-services boto3 amazon-cognito