Reputation: 31
Am new to aws development and was trying to do password less features using aws cognito's Custom Auth Flow, lambda triggers and the aws python SDK.
My problem is after the call to InitiateAuth, I always get the error below:
An error occurred (InvalidLambdaResponseException) when calling the InitiateAuth operation: Unrecognizable lambda output
Full traceback is:
Traceback (most recent call last):
File "test_custom_auth.py", line 52, in <module>
ClientId=client_id
File "/Users/jules/Repositories/snaaap/onemac-api/env/lib/python3.6/site-packages/botocore/client.py", line 320, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/Users/jules/Repositories/snaaap/onemac-api/env/lib/python3.6/site-packages/botocore/client.py", line 623, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.errorfactory.InvalidLambdaResponseException: An error occurred (InvalidLambdaResponseException) when calling the InitiateAuth operation: Unrecognizable lambda output
I can see thru cloudwatch logs that the defineAuthChallenge Trigger and createAuthChallenge Trigger calls are successful and was even able to print out logs to verify this.
I did the lambda functions first with Javascript, then with Python, just to try another method.
I tried to return the following in python (I am editing using the lambda editor console)
return event
result = {
"isBase64Encoded": False,
"statusCode": 200,
"headers": {},
"body": json.dumps(event)
}
return result
I tried to return the following in javascript (I am editing using the lambda editor console)
context.succeed(event)
callback(null, event)
context.done(event)
context.done(JSON.stringify(event))
And permutations of those mentioned above, but I still kept on getting the error :( Appreciate anyone that can help!
EDIT
Performed another request:
Below are the logs from defineAuthChallenge:
START RequestId: 14441740-cc65-11e8-a632-9508cbba464c Version: $LATEST
END RequestId: 14441740-cc65-11e8-a632-9508cbba464c
REPORT RequestId: 14441740-cc65-11e8-a632-9508cbba464c Duration: 6.70 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 20 MB
Below are the logs from **createAuthChallenge **:
START RequestId: 144995b6-cc65-11e8-8d2d-5388c84ccf95 Version: $LATEST
END RequestId: 144995b6-cc65-11e8-8d2d-5388c84ccf95
REPORT RequestId: 144995b6-cc65-11e8-8d2d-5388c84ccf95 Duration: 592.59 ms Billed Duration: 600 ms Memory Size: 128 MB Max Memory Used: 29 MB
Upvotes: 0
Views: 2925
Reputation: 31
Changed challengeMetaData
to challengeMetadata
in the response I am returning from my createAuthChallenge function. Learned that when you put an invalid key in the response attribute lambda will throw the InvalidLambdaResponseException
, though I hope next time cloudwatch can catch it.
Got an idea from @thomasmichaelwallace, and this article https://forums.aws.amazon.com/thread.jspa?threadID=237677.
Upvotes: 2