Flutter sign up confirm via phone otp in aws amplify

345

try amazon_cognito_identity_dart package.

//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);
Share:
345
Midhilaj
Author by

Midhilaj

I started coding life when I was studying in higher secondary class. Then I started to develop the application with "Visual Studio 2010". Opensource event in Kochin university was a turning point in my life which helped me to realize the power of open source. Then I started to use Ubuntu which helped me to learn a lot of tools, programming language, and framework. When I was in the 3rd semester in computer science and engineering, our new teacher forced me to develop an android app. From then I started to code in Android and I developed an app for our college. After getting the reviews, I realized that my skill is in coding. I spend more time in coding and now I can say that I am a professional programmer. I developed more than 20 apps. I focused on e-commerce app development and succeeded in that field. I also got 3 clients in e-commerce and successfully developed apps for them. I develop the admin website using angular2 since it helps to develop the website without refreshing for every action. All server request is done in the background and user feel the website like desktop software and in the future, I can make it as desktop software by using Electron (at that time open cart and PrestaShop admin website will refresh and take more time while performing any actions). My first server-side programming language is PHP (Rest API jacwright/RestServer and Slim Framework). I use firebase to develop 95% of my native app (Java, SQLite) and website(they are providing web hosting with SSL for free and it is highly secure and we don't need to worry about server-side script and server performance). My e-commerce app has the necessary features and an admin panel for admin to manage product, orders, delivery time, home page listing, category and category images, text field colors, etc I also successfully implemented an online payment gateway (instamojo) in my e-commerce apps I also developed an e-commerce app with the Flutter (Dart,sqflite ) using Shopify Rest API and implemented google map custom location picker. Flutter is amazing. It takes only a few days to develop the app with flutter when compared to app development time with android java. My technical guru is Google and stack overflow. My knowledge of coding life is from Google and StackOverflow. StackOverflow helped me to solve my doubts and issues during coding, at any time. I use Gitlab rather than GitHub because for the private project we need to pay for GitHub and my projects are not fully open-source. Gitlab allows publishing private project without any fee https://in.linkedin.com/in/midhilaj Flutter developer

Updated on December 01, 2022

Comments

  • Midhilaj
    Midhilaj over 1 year

    How to add phone and confirm sign up via phone otp and not with email otp