Is it possible to modify the statusCode returned by API Gateway when access is denied by a lambda authorizer?
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.
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.
limits with API gateway custom authorizer for number of requestsAccepted Answerasked 2 years ago
API Gateway Timeouts from Lambdaasked 3 years ago
Return a custom header from lambda authorizer in API-gateway (HTTP api)asked a month ago
Client API throttling in API GatewayAccepted Answer
Client API Throttling in API GatewayAccepted Answer
On an apigateway websocket is the status returned from the lambda handler?Accepted Answerasked 3 years ago
Is it possible to modify the statusCode returned by API Gateway when access is denied by a lambda authorizer?Accepted Answerasked 4 years ago
Is it possible to throw custom error message from API Gateway Lambda Authorizerasked 2 months ago
Lambda Authorizer with API Key enabled on API Gatewayasked 3 months ago
API Gateway - Gateway response - HTTP APIAccepted Answerasked a year ago