We have a CUSTOM_AUTH flow set up, and when we call initiateAuth method of Cognito API, DefineAuthChallenge lambda function gets called with an event:
{
"version": "$LATEST",
"triggerSource": "DefineAuthChallenge_Authentication",
"userName": "+12136185086",
"region": "us-west-2",
"userPoolId": "us-west-2_3059f26f871448f6b709cbcb1ea2d1c5",
"callerContext": {
"awsSdkVersion": "aws-sdk-unknown-unknown",
"clientId": "knpedd2zvd7zz70mzv06ge5kax"
},
"request": {
"session": [
{
"challengeName": null,
"challengeResult": true, // it shouldn't be true, since it is a first call
"challengeMetadata": null
}
],
"userAttributes": {
"name": "Lscwb Kczxc",
"phone_number": "+12136185086",
"phone_number_verified": "true",
"sub": "430ff8de-cdd5-4da5-94b5-5744625aabac",
"cognito:user_status": "CONFIRMED"
}
},
"response": {
"challengeName": null,
"failAuthentication": null,
"issueTokens": null
}
}
challengeResult
is not supposed to be true right away, the user should pass the authorization challenge first.