AWS Cognito custom authentication flow not works

22 Views Asked by At

I have set up Cognito with CUSTOM_AUTH and ALLOW_USER_SRP_AUTH. My goal is to authenticate users using ALLOW_USER_SRP_AUTH, and upon successful authentication, invoke CUSTOM_AUTH. This means that once a user successfully authenticates, they will receive an OTP on their registered email. After successfully verifying the OTP, the user will be able to sign in.

I have created three Lambda functions:

defineAuthChallenge: to define the authentication flow.

postAuthentication: to send the OTP to the user's registered email address.

verifyAuthChallenge: to verify the OTP.

I am testing this flow using the React Amplify package. The user authenticates successfully, but on the Cognito side, the defineAuthChallenge is not triggered after successful authentication. Only the postAuthentication Lambda function is triggered, and it sends the OTP successfully. However, when I attempt to send the OTP and the Cognito user in sendCustomChallengeAnswer(), I receive an error stating "missing required parameter session".

Could you please guide me on where I may have made a mistake?

0

There are 0 best solutions below