AWS API Gateway定制授权者奇怪的显示错误 [英] AWS API Gateway custom Authorizer strange showing error
本文介绍了AWS API Gateway定制授权者奇怪的显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这里是上下文:
- 我在API网关中设置了一个资源./user/company
- 该资源有2种方法.获取并发布.
- 我已经为此资源配置了自定义授权者.
问题:
- 我可以通过发送正确的授权信息来调用GET方法,并且可以得到预期的结果.
- 我尝试发送POST请求,但出现以下错误:
{
"message": "User is not authorized to access this resource"
}
- 如果我等了几分钟,然后调用POST方法,它将起作用.
- 如果在调用POST方法并获得结果后调用GET方法,它将显示与上述相同的错误.
此外,我已禁用了授权者的缓存.
In addition, I have disabled cache for the authorizer.
什么原因导致了此问题?
What might have caused this issue?
推荐答案
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
简短版本:
- 将客户授权者的TTL设置为0
- 将自定义授权者策略资源设置为"*"
我已经尝试了每种解决方案,并且都通过用户无权访问此资源"解决了该问题.对我来说.
I've tried each solution and they both solved the issue with "User is not authorized to access this resource" for me.
这篇关于AWS API Gateway定制授权者奇怪的显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文