Firebase Two-Factor Auth in Flutter

Viewed 1394

I have a flutter app and I am using firebase for authentication purpose. I have a website as well, I recently implemented 2 Factor Auth using firebase.

On the web side, I login the user, catch the Mfa error and using the resolver proceed with the OTP verification via the phone number or email.

I am trying to implement the same thing on the flutter side, While I have found the modules for implementing recaptcha and OTP verification, I am unable to figure out the resolver bit, Any help would be appreciated. I read on some posts that MFA is not possible with Flutter as of this moment, is this so ? I have been unable to find anything on the docs so far regarding mfa for flutter.

Here is what I have so far :

void attemptLogin() async {
    try {
      await _auth.signInWithEmailAndPassword(email: email, password: password);

      //  Add logic for non 2fa users
    } on FirebaseAuthException catch (err) {
      if (err.code == 'second-factor-required') {
        // Use the resolver and intiate recaptcha and OTP verification process. How to do this ?
      } else {
        // Show relevant erro message
      }
    }
  }
1 Answers

firebase_auth multi-factor authentication is still in progress as mentioned on this thread. MFA has been available on web and native mobile SDKs for a while now. Flutter has added MFA feature on their roadmap, but no ETA at present.

Related