Api gateway - Api key- 403- "message": "Forbidden"

Aws api gateway with api giving the following error
 {"message": "Forbidden"} 
I am working with aws api gateway with nodejs as server. I defined my api using swagger yaml and  deployed to aws api gateway.

Next step is to implement authentication to the api.

Api gateway itself providing authentication mechanism.
Using api key to authenticate the request.

if API keys are enabled, you can set the x-api-key:{api_key} name/value pair here

If the api key is enabled for the api method, then you can set x-api-key: {api_key}  name/value pair in the header.

I used swgger ui and set the api key, but didnt work.
I resolved after few hours struggling.
Change frpm window.swaggerUi.api.clientAuthorizations.add( "bearer", apiKeyAuth ); with window.swaggerUi.api.clientAuthorizations.add( "jsonWebToken", apiKeyAuth );

The name you will assign to the ApiKeyAuthorization from client need to match the name you give the security scheme under swagger definitions.


Popular posts from this blog

What is Android ?