Sign in a user through OTP
- Requires either an email or phone number.
- This method is used for passwordless sign-ins where an 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 an OTP.
- If you're using phone, you can configure whether you want the user to receive an OTP.
- The magic link's destination URL is determined by the
SITE_URL
. You can modify theSITE_URL
or add additional redirect urls in your project.
Parameters
email
Optional
StringEmail address to send the magic link or OTP to.
phone
Optional
StringPhone number to send the OTP to.
emailRedirectTo
Optional
StringThe URL to redirect the user to after they click on the magic link.
shouldCreateUser
Optional
boolIf set to false, this method will not create a new user. Defaults to true.
data
Optional
Map<String, dynamic>The user's metadata to be stored in the user's object.
captchaToken
Optional
StringThe captcha token to be used for captcha verification.
channel
Optional
OtpChannelMessaging channel to use (e.g. whatsapp or sms). Defaults to OtpChannel.sms
.
await supabase.auth.signInWithOtp(
email: '[email protected]',
emailRedirectTo: kIsWeb ? null : 'io.supabase.flutter://signin-callback/',
);