Home > Back-end >  aws api gateway api key access
aws api gateway api key access

Time:11-10

I have deployed an AWS apigateway -> lambda integration.

The apigateway has one POST method which requires an api_key.

I have added that api key in my request headers under the X-API-Key key and the x-api-key and every time I still get a:

{
    "message": "Forbidden"
}

I am running out of ideas, there are definitely no typos and the key is enabled as a HEADER source too.

Does anyone know what I might be missing in order to have the request authenticate properly?

I am invoking it like so:

curl --location --request POST 'https://my-endpoint/resource' \
--header 'X-Api-Key: mykey'

Cheers

CodePudding user response:

For anyone coming here to get this answer, an API needs to have a usage plan in order to validate the api-key.

This was failing because there was no usage plan.

CodePudding user response:

Useful Checklist:

  • Api key is created
  • Api usage plan is created
  • Api stage is created
  • Api usage plan is associated with the api stage
  • Api usage plan is associated with the api key
  • Api key is sent in http header x-api-key
  • Related