如何将状态代码设置为429并从API网关自定义授权程序返回自定义消息?
答案 0 :(得分:0)
我也在寻找这个解决方案。我得到了自定义消息和放大器等消息我们的自定义授权程序中的状态代码未启用。 请参考此处 - https://forums.aws.amazon.com/thread.jspa?threadID=226689
但是,为自定义授权程序编码时发现您可以发送401或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
答案 1 :(得分:0)