Supabase Auth MFA Guide — Adding TOTP and OTP to Flutter Apps
Supabase Auth has built-in MFA support. Here's how to add TOTP (Google Authenticator compatible) to your Flutter app — covering enrollment, verification, and RLS enforcement.
How MFA Works
User signs in (email + password) — AAL1
If MFA is enrolled → Challenge issued
User enters 6-digit code
Auth upgraded to AAL2
TOTP Enrollment
class MFAService { final SupabaseClient _client ; MFAService ( this . _client );
Future < TOTPSetupResult > enrollTOTP () async { final response = await _client . auth . mfa . enroll ( factorType: FactorType . totp ); return TOTPSetupResult ( id: response . id , qrCodeUri: response . totp !. qrCode , secret: response . totp !. secret , ); } }
Enter fullscreen mode
Exit fullscreen mode
// QR code display QrImageView ( data: setup .…