使用HTTP代理访问AWS API Gateway中的标头?

编程入门 行业动态 更新时间:2024-10-26 10:30:08
本文介绍了使用HTTP代理访问AWS API Gateway中的标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用AWS API Gateway及其HTTP代理

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

我需要通过AWS API Gateway将Authorization标头传递给我的终端节点

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

我尝试过的事情:

设置方法请求类似,

集成请求设置

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 } }

这也不起作用。

有人可以给我一些有关如何实现的提示吗?

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

推荐答案

最近我不得不尝试使用API​​ Gateway HTTP代理将AWS SigV4 HTTP请求传递到终端节点。 经过测试和调试后,发现授权正在被使用并且没有通过! 因此,在将请求发送到API网关时-我发送了Authorization和Authorization的副本作为另一个标头 myauth。 (由于请求来自我自己的客户端,所以我能够执行此操作。)

Recently I had to try using an API Gateway HTTP proxy to pass an AWS SigV4 HTTP request to an endpoint. After testing and debugging found that the Authorization is being consumed and not passed! So while sending the request to the API Gateway - I sent Authorization and a copy of the Authorization as another header "myauth". (I was able to do this since the request is coming from my own client.)

在方法请求中,我添加了Authorization和myauth作为HTTP标头 方法请求-HTTP标头

In the method request I added Authorization and myauth as HTTP Headers Method Request - HTTP Headers

在集成请求-HTTP标头中,我将myauth映射到授权,然后将其转发到端点

In the Integration Request - HTTP Headers I mapped myauth to Authorization before it was forwarded to the endpoint

集成请求-HTTP标头

不知道这是否是最好的方法,或者可能有任何潜在的问题,但这可行!希望这可以帮助某人或提供一些想法。

Dont know if this is the best way to do this or if there could be any potential issues but this worked! Hope this helps someone or gives some ideas.

更多推荐

使用HTTP代理访问AWS API Gateway中的标头?

本文发布于:2023-11-10 10:36:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575123.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:AWS   HTTP   Gateway   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!