Rest api gateway, custom api key header name

0

I created the objects needed to enable 'API Key Required'=true on the API gateway. But I am not able to change the default x-api-key header name. My understanding is that since the api gateway supports openapi 3.0, so in the openapi file, included into Gateway config, I added the sections:

components
    securitySchemes:
        api_key:
        type: "apiKey"
        name: "custom-header-name"
        in: "header"
security:
  - api_key: []

Unfortunately, after deploying on AWS via cloud formation, the settings are overwritten and the "x-api-key" header is still expected instead of "custom-header-name"

1 個回答
1
已接受的答案

As stated in the documentation "header sourced API Keys" must use the "x-api-key" header.

https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-key-source.html#:~:text=key%20as%20the-,X%2DAPI%2DKey,-header%20of%20each

If you want to call the API key-required methods without explicitly supplying any API key. You can use the authorizes-sourced API Keys:

https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-key-source.html#:~:text=authorizer%2Dsourced%20API%20keys

AWS
vtjean
已回答 7 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南