Search code examples
amazon-web-servicesaws-lambdaauthorizationaws-api-gateway

API Gateway authorization


I am building a web site as a part of a project of mine and I got a bit stuck.

I created an API Gateway that will help me communicate with my AWS Lambda (That is basically the backend side that is calling a text-to-speech model).

I believe my API Gateway is set properly, as when I try to test the POST method, I get back the expected result. However, when I try to access the API using the same request from my website directly, I get a 401 UNAUTHORIZED.

This is my resource: enter image description here And by testing that works I meant using the TEST button and supply the expected body.

I can tell that the API Gateway testing does state that when triggered, they invoke the method directly and skip the authorization process:

Make a test call to your method. When you make a test call, API Gateway skips authorization and directly invokes your method

I tried setting an Authorizer from the Gateway interface, create an API-key for my API, but no success so far. In the above picture, "auth" is the Authorizer I set.

Any suggestions?


Solution

  • Not a full answer to the exact question, but what solved the issue for me was the understanding that changes in API Gateway takes a few minutes to deploy. What happened is every time I deployed a change I immediately tried to access the API from my web page and this way debugging was impossible.

    So - if a change is made on API Gateway, wait a few minutes before you try again :)