Flutter: Sign in a user through OTP
- Requires either an email or phone number.
- This method is used for passwordless sign-ins where a OTP is sent to the user's email or phone number.
- If you're using an email, you can configure whether you want the user to receive a magiclink or a OTP.
- If you're using phone, you can configure whether you want the user to receive a OTP.
- The magic link's destination URL is determined by the
SITE_URL
. You can modify the SITE_URL
or add additional redirect urls in your project.
Examples
Sign in with email.
await supabase.auth.signInWithOtp(
email: 'example@email.com',
emailRedirectTo: kIsWeb ? null : 'io.supabase.flutter://signin-callback/',
);
Sign in with SMS OTP.
await supabase.auth.signInWithOtp(
phone: '+13334445555',
);
Sign in with WhatsApp OTP
await supabase.auth.signInWithOtp(
phone: '+13334445555',
channel: OtpChannel.whatsapp,
);