For AI agents: a documentation index is available at /llms.txt. A markdown version of this page is available at the same URL with .md appended (or via Accept: text/markdown).
Skip to main content

Enable MFA

The enableMFA method triggers multi-factor authentication (MFA) setup for a signed-in user, adding an additional recovery factor to protect wallet access. It accepts an optional LoginParams parameter and returns true when the setup flow completes.

The SDK reuses the auth connection from the user's current session.

  • If you use a default sign-in provider, call enableMFA() without arguments.
  • If you use a custom auth connection that needs extra sign-in options (for example, Auth0), pass a LoginParams object with the same extraLoginOptions you used to sign in.
warning

Users who signed in with an idToken (single-factor authentication) can't enable MFA. enableMFA throws Web3AuthError.enabledMfaNotAllowed for these users. It throws Web3AuthError.mfaAlreadyEnabled if the user already has MFA enabled, and Web3AuthError.noUserFound if no user is signed in.

Usage​

do {
let isMFAEnabled = try await web3Auth.enableMFA()
} catch {
print(error.localizedDescription)
// Handle Error
}
On this page