我想通過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