Is it possible to customize API Gateway custom authorizer response message and status code on unauth


How do I set the status code to 429 and return a custom message from an API Gateway custom authorizer?


Am also searching for this solution. i got messages like custom message & status code from our custom authorizer is not enabled. refer here - <a href="https://forums.aws.amazon.com/thread.jspa?threadID=226689" rel="nofollow">https://forums.aws.amazon.com/thread.jspa?threadID=226689</a>

But while coding for custom authorizer found that you can send either 401 or 403

//this will send status - 401 , body - {"message":"unauthorized"} context.fail('Unauthorized') /*this will send status 403 , body - { "Message": "User is not authorized to access this resource with an explicit deny" }*/ context.succeed({ "policyDocument": { "Version": "2012-10-17", "Statement": [ { "Action": "execute-api:Invoke", "Effect": "Deny", "Resource": [ "arn:aws:execute-api:ap-south-1:************/Development/*/*" ] } ] } }) note : like allow you have to create deny policy


The functionality here is a bit limited. But I've found that by editing the Gateway Responses for the 403 and 401 status codes. My custom message gets shown to users.

For example, by saving the below and re-deploying the API. I now get my custom message when the lambda authorizer returns a deny policy.

<a href="https://i.stack.imgur.com/fSu1P.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/fSu1P.png" data-original="https://i.stack.imgur.com/fSu1P.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>


  • Parse SQL file with PL/SQL and DML/DDL using cx_Oracle in python
  • Delphi XE - calling Crystal Reports
  • Make Amazon S3 files available only to logged in users
  • Permission in calling service from another app
  • Is it okay to delete a POSIX timer in the event handler function?
  • Cannot terminate threads
  • AWS Cloudwatch not triggering on API calls
  • Closing thread using ExitThread - C
  • Is creating a new version of an object in AWS S3 eventually consistent or read-after-write consisten
  • Grunt module(s) to upload all static assets to S3 / CloudFront, replace paths, and invalidate old as
  • AWS Cognito- get user information with ID
  • Dynamically create AWS IoT topic
  • Special chars in Amazon S3 keys?
  • Basic defensive programming [duplicate]
  • node.js POST request fails
  • TFS - how do I sum child task hours to parent
  • How to make R's read_csv2() recognise the text characters properly
  • Element.tagName for python not working
  • Graphics.CopyFromScreen [Web application] + The handle is invalid
  • How solve “Qt: Untested Windows version 10.0 detected!”
  • Install PHP intl extension on MacOS
  • Retrieve list of sent friend requests from friend_request FQL table
  • Alternative To body {overflow:scroll;} That Will Prevent Page Jostling/Wriggling?
  • With Hadoop, can I create a tasktracker on a machine that isn't running a datanode?
  • Play WS (2.2.1): post/put large request
  • NHibernate Validation Localization with S#arp Architecture
  • How can I send an e-mail from a vbs script
  • C# - Is there a limit to the size of an httpWebRequest stream?
  • Spray.io: When (not) to use non-blocking route handling?
  • Accessing IRQ description array within a module and displaying action names
  • Updating server-side rendering client-side
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • How to pass list parameters for each object using Spring MVC?
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Getting Messege Twice Using IMvxMessenger
  • sending mail using smtp is too slow
  • How to Embed XSL into XML
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF