Access headers in AWS API Gateway using HTTP Proxy?

馋奶兔 提交于 2019-12-04 23:45:10

问题


I'm using AWS API Gateway and it's HTTP Proxy,

I need to pass Authorization header to my endpoint through AWS API Gateway

Things I've tried:

Setting Method Request like so,

Integration Request setup

This doesn't work, my app doesn't receive the Authorization header,

Also I've tried using mapping template

{
  "method": "$context.httpMethod",
  "body" : $input.json('$'),
  "headers": {
    #foreach($param in $input.params().header.keySet())
    "$param": "$util.escapeJavaScript($input.params().header.get($param))" #if($foreach.hasNext),#end

    #end
  },
  "queryParams": {
    #foreach($param in $input.params().querystring.keySet())
    "$param": "$util.escapeJavaScript($input.params().querystring.get($param))" #if($foreach.hasNext),#end

    #end
  },
  "pathParams": {
    #foreach($param in $input.params().path.keySet())
    "$param": "$util.escapeJavaScript($input.params().path.get($param))" #if($foreach.hasNext),#end

    #end
  }  
}

This also doesn't worked.

Could Anyone give me some hint on how this might be accomplished ?


回答1:


API Gateway strips the AWS SigV4 Authorization header due to security reasons. If you are using other Authorization mechanism like OAuth, the header wouldn't be stripped.



来源:https://stackoverflow.com/questions/35017297/access-headers-in-aws-api-gateway-using-http-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!