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
已提問 6 年前檢視次數 1394 次
1 個回答
0
已接受的答案

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.

已回答 6 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南