How to resend OTP code to mail using MFA widget javascript

Hi Everyone,

I am trying the MFA widget javascript to customize the UI, but I could not able to find an option/method to trigger resend of OTP to mail

using the script tag
<script src="//cdn.auth0.com/js/mfa-widget/mfa-widget-1.8.min.js"></script>

Need your help on how to trigger new OTP code to mail by triggering resend

1 Like

To trigger a resend of the OTP code using the Auth0 MFA Widget JavaScript library, you can use the auth0.mfa.resendOTP() method. This method will send a new OTP code to the user’s registered email address. Here is an example of how to use it:

<script src="//cdn.auth0.com/js/mfa-widget/mfa-widget-1.8.min.js"></script>
<script>
  var mfaWidget = new Auth0MFAWidget({
    domain: 'YOUR_AUTH0_DOMAIN',
    clientId: 'YOUR_AUTH0_CLIENT_ID',
    ...
    // Other configuration options
  });

  // Trigger resend OTP code
  function resendOTP() {
    mfaWidget.resendOTP()
      .then(function() {
        // Resend successful
        console.log('OTP code resent');
      })
      .catch(function(error) {
        // Handle resend error
        console.error('Error resending OTP code:', error);
      });
  }
</script>

You can call the resendOTP() method whenever you want to trigger a new OTP code to be sent to the user’s email address.