I have an aws api gateway api that was using a api key to authenticate requests. It was tied to a usage plan and it was working. Later we needed a new api key name and value. I removed the old api key from usage plan and added the new api key to usage plan. Re-deployed the stage. Now when using the new api key name and value in the header the requests always return as 403 forbidden. Not sure what is wrong. Everything looks right.
1 Answers
1
votes
The header for an API key must be x-api-key, without this the API will return a 403 when API key authentication is enabled for the stage.
You distribute API keys to your customers and require them to pass the API key as the
X-API-Keyheader of each incoming request.
The name of the key does not need to share this, in fact you can use it to describe the application/user who will be using this API key with your integration.
To call your API you would use the below where $key is the API key value.
curl -H "x-api-key: $key" https://xxxxxx.execute-api.us-west-2.amazonaws.com/get-token
You can find out more information about this in the Choose an API key source documentation.
x-api-key. The name of the key in API Gateway does not matter (an API can have many keys associated with it). - Chris Williams