AWS API Gateway custom Authorizer strange showing error

Arman Fatahi picture Arman Fatahi · May 14, 2018 · Viewed 9.8k times · Source

Here is the context:

  • I set up a resource in the API gateway. /user/company
  • This resource have 2 methods. Get and POST.
  • I have configured a custom Authorizer for this resource.

The problem:

  • I can call the GET method by sending right authorization information and I get the results as expected.
  • I try to send a POST request and I get the following error:

  • If I wait for few minutes, then call the POST method, it will work.
  • If after calling the POST method and getting the results I call GET method, it will show the same error as mentioned above.

In addition, I have disabled cache for the authorizer.

enter image description here

What might have caused this issue?

Answer

Orest picture Orest · Nov 1, 2018

This could be fixed in two ways that are described in buggy's answer: https://forum.serverless.com/t/rest-api-with-custom-authorizer-how-are-you-dealing-with-authorization-and-policy-cache/3310

Short version:

  1. Set TTL for customer authorizer to 0
  2. Set custom authorizer policy resource as "*"

I've tried each solution and they both solved the issue with "User is not authorized to access this resource" for me.