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 Antwort
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
EXPERTE
beantwortet vor einem Monat
  • There is no issue with the authorizer. It works fine. I just want to find a way to manipulate the unauthorized response body

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen