> ## 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 Swift 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/swift/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 the same `WebAuthenticationSession` sheet, 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 Face ID, Touch ID, or the device 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 through `loginExternalWallet`, which can owe a second factor (see below).

## With the Stage-Based Methods

The stage-based methods (`initiateAuthFlow`, `handleVerificationCode`, `handleOAuth`, and `loginExternalWallet`) can't host the second-factor step. When an account must complete it, they cancel the pending sign-in and throw `ParaTwoFactorRequiredError`. 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 error and tell the user. Use the `authenticate` methods, which complete the second factor once Para's updated authentication flow runs for your app:

```swift AuthenticationView.swift theme={null}
do {
    let state = try await paraManager.initiateAuthFlow(auth: auth)
    // Existing handling, unchanged
} catch is ParaTwoFactorRequiredError {
    // This account requires 2FA, which this sign-in flow can't complete
    showError("Two-factor authentication is required to sign in.")
}
```

`ParaTwoFactorRequiredError` is its own type rather than a `ParaError` case, so existing `switch` statements over `ParaError` keep compiling. Its `mode` is `.verify` when the account has a second factor to verify and `.enroll` when it must set one up first (`nil` when Para didn't say), and `methods` lists the second-factor methods Para offered.

## Next Steps

* [Email & Phone Login](https://docs.getpara.com/v3/swift/guides/email-phone-login.md)
* [Swift API Reference](https://docs.getpara.com/v3/swift/api/sdk.md)


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