I am using a lambda function as an authenticator for my HTTP API-Gateway and I figured three cases in Simple Response-
- when "isAuthenticated" = True --> 200 and the request goes through
- when "isAuthenticated" = False --> 403 and it return Forbidden
- when Authentication key is missing in the header --> 401
I want to return 401 when "isAuthenticated" = False or find a way to send 401 error code from the API-Gateway/authorizer, in the REST API-Gateway this is possible by raising an error/exception with "Unauthorized". But This is not possible for REST API-Gateway.
I have tried almost every way to send a response from simple as well as policy HTTP API-Gateway like raising Exceptions/Error/callback even returning null.
Is there a way for me to return 401 when the user is not authenticated? There are many similar questions on StackOverflow but mostly for REST API-Gateway, my question is specific to HTTP API-Gateway.