Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
Need help for cognito authentication flow with MFA to remember the device while challenging for MFA

I am using aws cognito service for authentication, followed https://github.com/aws-amplify/amplify-js/tree/master/packages/amazon-cognito-identity-js this documentation.

My login flow is something like this:

import {AuthenticationDetails,CognitoUser,CognitoUserPool} from 'amazon-cognito-identity-js';

const authenticationData = {
  Username: <username>,
  Password: <password>
};
const authenticationDetails = new AuthenticationDetails(
  authenticationData
);

const userData = {
  Username: <username>,
  Pool: <userPoolId>,
};

const cognitoUser = new CognitoUser(userData);

cognitoUser.authenticateUser(authenticationDetails, {
  onSuccess: (result) => {
    const accessToken = result.getAccessToken().getJwtToken();
    console.log('access token --> ', accessToken);

  },
  onFailure: (err) => {
    console.log("error",err.message);
  },
  mfaRequired: function (codeDeliveryDetails) {
    var verificationCode = prompt('Please input verification code', '');
    cognitoUser.sendMFACode(verificationCode, this);
  },

})

I've already created one AWS Cognito UserPool and the enabled MFA for the same. enter image description here

In signin flow is working and the user is authenticated by multi-factor-authentication and I'm getting the access token.

But now I want not to verify mfa for the same device multiple times. Something like remember the device for the specific user for new 10-15 logins or next 7-15 days.

I checked the docs and seemed I can achieve this with aws amplify.

async function rememberDevice() {
  try{
    const result = await Auth.rememberDevice();
    console.log(result)
  }catch (error) {
    console.log('Error remembering device', error)
  }
}

But aws amplify is not working for me as it has an open issue. https://github.com/aws-amplify/amplify-js/issues/9204

In my cognito user pool I tried to set this one, but it's not helping as well. enter image description here

Is there any other option available in Cognito api to achieve my requirement?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!