> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getpara.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Login Two-Factor Authentication

> How login two-factor authentication works in the Para Flutter SDK.

## Overview

Login two-factor authentication (2FA) asks a user for a second factor after their first sign-in step, such as verifying their email or phone. Turn it on and choose the methods users can enroll in the Developer Portal's [Login Two-Factor Authentication setting](https://docs.getpara.com/v3/flutter/setup/developer-portal-security.md#login-two-factor-authentication): Off (users are never asked), Optional (users who enroll are asked for it), or Required (every user enrolls at their next sign-in).

When a sign-in needs a second factor, the user either enrolls one (when your app requires 2FA and they don't have one yet) or verifies one they already have. Para hosts both steps on its own pages. Your app doesn't build 2FA screens.

If an account keeps its wallet on the user's device behind a passkey, that passkey is its second factor: the user doesn't set up an authenticator app and isn't asked for anything extra at sign-in. Accounts that keep their wallet on the device behind a password or PIN set up an authenticator app like other users.

## With the `authenticate` Methods

`authenticateWithEmailOrPhone` and `authenticateWithOAuth` need no code changes. On Para's updated authentication flow, the Para-hosted page runs the second-factor step after the first one, in your `webAuthenticationSession`, and the call returns its `AuthenticationResult` once the user completes it.

A few sign-ins don't ask for a second factor:

* **Native passkey sign-in.** A passkey created on the device that protects the user's wallet is bound to the device and asks for the device's biometrics or passcode, so signing in with it satisfies 2FA on its own.
* **External wallet sign-in with `authenticateWithExternalWallet`** on Para's updated authentication flow. The session proves control of the external wallet only and can't sign with the account's embedded Para wallets, so it doesn't owe a second factor. Without the updated flow, the call signs in with the wallet address instead, which can owe a second factor (see below).

## With the Stage-Based Methods

The stage-based methods (`initiateAuthFlow` or `signUpOrLogIn`, `verifyOtp`, `verifyOAuth`, and `loginExternalWallet`) and the wallet connectors' `connect()`, which signs in with the wallet address, can't host the second-factor step. When an account must complete it, they cancel the pending sign-in and throw a `ParaBridgeException` with code `two_factor_required`. The `authenticate` methods throw it too when Para's updated authentication flow isn't enabled for your app, because they then sign in through these methods.

Para decides which sign-in experience runs for your app, so catch the code and tell the user. Use the `authenticate` methods, which complete the second factor once Para's updated authentication flow runs for your app:

```dart lib/views/login.dart theme={null}
try {
  final result = await para.authenticateWithEmailOrPhone(
    auth: Auth.email(email),
    webAuthenticationSession: webAuthSession,
    verificationCodeProvider: promptForCode,
  );
  completeLogin(isNewUser: result.isNewUser);
} on ParaBridgeException catch (e) {
  if (e.code == 'two_factor_required') {
    // This account requires 2FA, which this sign-in flow can't complete
    showError('Two-factor authentication is required to sign in.');
    return;
  }
  rethrow;
}
```

The exception's `details` carry `mode` (`verify` when the account has a second factor to verify, `enroll` when it must set one up first) and `methods`, the second-factor methods Para offered. Either can be null.

## Next Steps

* [Authenticate Users](https://docs.getpara.com/v3/flutter/setup.md#authenticate-users)
* [Flutter API Reference](https://docs.getpara.com/v3/flutter/api/sdk.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.