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 Answer
1
Accepted Answer

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
answered 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions