我想通过java SDK实现自定义授权者lambda函数。有人可以告诉我从我的lambda函数中预期的JSON响应的确切格式。另外,我应该返回输出格式(JSON对象或策略对象)。AWS API网关自定义授权者
{
"policyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": "execute-api:Invoke",
"Resource": [
"arn:aws:execute-api:us-east-1:1234567:myapiId/staging/POST/*"
],
"Effect": "Allow"
}
]
},
"principalId": "User123"
}
这是格式我在输出JSONObject
格式提供,但得到的错误
Mon Apr 10 09:42:35 UTC 2017 : Endpoint request body after transformations: {"type":"TOKEN","authorizationToken":"ABC123","methodArn":"arn:aws:execute-api:ap-southeast-1:007183653813:ohlqxu9p57/null/GET/"} Mon Apr 10 09:42:36 UTC 2017 : Execution failed due to configuration error: Authorizer function failed with response body: {"errorMessage":"An error occurred during JSON serialization of response","errorType":"java.lang.RuntimeException","stackTrace":[],"cause":{"errorMessage":"com.fasterxml.jackson.databind.JsonMappingException: JsonObject (through reference chain: com.google.gson.JsonObject[\"asString\"])","errorType":"java.io.UncheckedIOException","stackTrace":[],"cause":{"errorMessage":"JsonObject (through reference chain: com.google.gson.JsonObject[\"asString\"])","errorType":"com.fasterxml.jackson.databind.JsonMappingException","stackTrace":["com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:210)","com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:177)","com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:199)","com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:683)","com.f [TRUNCATED] Mon Apr 10 09:42:36 UTC 2017 : AuthorizerConfigurationException
任何帮助将是巨大的。在此先感谢
我已尝试和许多其他things.Can妳告诉我的天气。我应该返回JSON字符串或JSON对象作为我的自定义授权lambda函数的输出!? – dpanshu