How to do a password less signin in flutter with AWS
604
I was able to do with this package: amazon_cognito_identity_dart_2
//Create a cognito user
CognitoUser cognitoUser1;
//Send OTP
cognitoUser1 = CognitoUser(phoneNumber.text, widget.userPool);
try {
CognitoUserSession cognitoUserSession =
await cognitoUser1.initiateAuth(
AuthenticationDetails(
authParameters: [
AttributeArg(
name: 'phone_number',
value: phoneNumber.text,
),
],
),
);
} catch (cognitoUserCustomChallengeException) {}
//Authenticate the user
CognitoUserSession cognitoUserSession = await cognitoUser1.sendCustomChallengeAnswer(otp.text);
print("jwtToken " + cognitoUserSession.accessToken.jwtToken);
print("refreshToken " + cognitoUserSession.refreshToken.token);
Author by
Praharsh Bhatt
I'm not an entrepreneur, nor a CEO. I'm a nerdy programmer who likes to have opinions on Twitter.
Updated on December 28, 2022Comments
-
Praharsh Bhatt over 1 year
I am unable to know how to do passwordless signin with OTP using cognito in flutter. I just need assistance with the flutter code for sending the OTP and answering the auth challenger with any working cognito/amplify package.