Postman for Api Gateway中的设置标头如何通过Cognito进行身份验证?

时间:2017-10-24 21:03:07

标签: amazon-web-services postman aws-api-gateway amazon-cognito amazon-cognito-facebook

我使用AWS Identity Pool和Facebook提供商来验证客户端。我需要使用Api Gateway调用AWS Lambda。从Cognito,使用Facebook令牌,我收到了凭证:AccessKeyId,SecretKey和SessionToken。

使用此凭据,我应该如何设置标头请求来调用我的Lambda?

Api Gateway设置(测试调用我的lambda)

enter image description here

我尝试调用我的api,它返回“请求中包含的安全令牌无效。”

enter image description here

谢谢!

3 个答案:

答案 0 :(得分:3)

请为邮递员试试这个:

http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-use-postman-to-call-api.html

在“授权”下拉列表中选择 AWS签名选项,并使用密钥和密码填写字段,单击“更新”。邮递员将为您签署请求。

并确保分配给您的cognito用户的角色可以访问调用apig。

答案 1 :(得分:2)

您必须手动设置' x-amz-security-token '在Postman中并传递该标题中的标记。

答案 2 :(得分:2)

JoshuaC Vijayanath Viswanathan 谢谢你们俩。根据您的建议,我解决了这个问题。

我做了以下步骤:

  1. 设置 AWS签名,然后点击" 更新请求"
  2. enter image description here

    1. 添加标题" X-Amz-Security-Token "使用 SessionToken
    2. enter image description here