We are using AWS Lambda Authorizer with API Gateway to protect our downstream API's.
Below is the code snippet from our Java based lambda authorizer
Statement statement = Statement.builder()
.resource(input.getMethodArn()).effect(effect)
.build();
PolicyDocument policyDocument = PolicyDocument.builder()
.statements(
Collections.singletonList(statement)
).build();
return AuthorizerResponse.builder()
.principalId(userId)
.policyDocument(policyDocument)
.context(ctx)
.build();
With correct token (effect = "Allow"): getting proper API response from API
With incorrect token (effect = "Deny") Getting 403 HTTP response code.
We need 401 ("Unauthorized") as a response, Can someone pls help how to do this ? we have lambda authorizer written in java.