Change REST API Gateway lambda authorizer response

0

Currently, I return this

{
          "principalId": "user",
          "policyDocument": {
            "Version": "2012-10-17",
            "Statement": [
              {
                "Action": "execute-api:Invoke",
                "Effect": "Allow" if isAuthorized else "Deny",
                "Resource": self.resource
              }
            ]
          }
        }

I get a message like this now in the authorizer response body if unauthorized,

{
    "message": "Unauthorized"
}

How can I manipulate this so that the message when unauthorized is changed?

1 Answer
0

Have a look at this: https://repost.aws/knowledge-center/api-gateway-401-error-lambda-authorizer, as it could be issues with configuration or usage/lack of tokens.

Also double check whether you resource policy may have a role into this.

profile picture
EXPERT
answered a month ago
  • There is no issue with the authorizer. It works fine. I just want to find a way to manipulate the unauthorized response body

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions