I understand that you want Websocket API to return 401 status code to client, without returning unauthorized error response from Lambda authorizer. REST API supports Gateway Response, which can be used to modify 403 status code from lambda authorizer to customized error response, including 401 status code.
At this time, Websocket API does not support Gateway Response. We already have a feature request open with the service team, regarding this. While I am unable to comment on if/when this feature may get released, I request you to keep an eye on our What's New and Blog pages for any new feature announcements.
http authorizer lambda permissionsAccepted Answerasked 4 months ago
Return a custom header from lambda authorizer in API-gateway (HTTP api)asked 2 months ago
Is it possible to update the user-defined authorizer context (i.e., event.requestContext.authorizer.context) after the initial authorizer lambda has already run?asked 8 months ago
Passing a custom message from Websocket API Lambda authroizer to the clientasked 2 months ago
On an apigateway websocket is the status returned from the lambda handler?Accepted Answerasked 3 years ago
Is it possible to return 401 error from WebSocket API Gateway Lambda Authorizer without throwing an error?asked a month ago
Lambda Authorizer with API Key enabled on API Gatewayasked 5 months ago
Are API Gateway Websocket APIs treated as asynchronous?asked 2 years ago
Is it possible to throw custom error message from API Gateway Lambda Authorizerasked 4 months 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