Custom Lambda Authorizer returning blank error message

The Custom lambda authorizer works fine. But when the token fails validation, i get the following along with status code 500.
{
“message”: null
}

How can i add a more custom error message

Hello,

I don’t think you can send a custom message. However, you can send a 401 HTTP status code by returning “Unauthorized” or 403 by returning a policy with effect “Deny” (instead of “Allow”).

You can find more details here : https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html

Hope it helps

If I throw an error like throw new Error("blabla") from the lambda-authorizer, why the response is not {message: "blabla"}?

1 Like