【发布时间】:2016-12-18 05:54:24
【问题描述】:
我正在尝试向 AWS API Gateway 发送经过身份验证的请求。客户端将针对 Cognito 您的用户池进行身份验证,然后从与用户池中已登录用户对应的关联 Cognito 身份池获取令牌。我正在尝试使用 Postman 模拟这样的请求。
This post 建议可以使用命令aws cognito-identity get-credentials-for-identity 来获取 Postman 签署请求所需的 AccessKeyId 和 SecretKey。但是,当我尝试使用 Cognito 用户池控制台中的用户使用 sub 属性运行它时:
$ aws cognito-identity get-credentials-for-identity --identity-id aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
An error occurred (ValidationException) when calling the GetCredentialsForIdentity operation: 1 validation error detected: Value 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee' at 'identityId' failed to satisfy constraint: Member must satisfy regular expression pattern: [\w-]+:[0-9a-f-]+
$ aws cognito-identity get-credentials-for-identity --identity-id us-east-1:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
An error occurred (ResourceNotFoundException) when calling the GetCredentialsForIdentity operation: Identity 'us-east-1:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee' not found.
如果我尝试使用 AWS 控制台中显示的关联身份池中的身份 ID(我选择了一个具有 2 个“链接登录”的身份 ID),也会发生同样的事情。
【问题讨论】:
标签: amazon-web-services postman amazon-iam amazon-cognito aws-api-gateway