Is it possible to modify the statusCode returned by API Gateway when access is denied by a lambda authorizer?

0

A customer is migrating an API from Apigee to API Gateway. Currently their API returns 401 Unauthorized when a request is denied because the token is invalid. They want to maintain same status code when possible to avoid having to ask their partners to modify their code to handle different status code.

By default API Gateway returns a 403 Forbidden when the request is denied by the Lambda Authorizer. I know that is possible to provide custom messages based on $context. authorizer.key, but have not found a way to change the statusCode returned by API Gateway.

AWS
preguntada hace 6 años1393 visualizaciones
1 Respuesta
0
Respuesta aceptada

You can use Gateway Response to modify the status code, body, and headers of the response. Choose the 'Unauthorized' gateway response type and configure as desired.

respondido hace 6 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas