简体   繁体   中英

aws api gateway api key access

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM