Verify and log in through OTP
- The
verifyOtp
method takes in different verification types. If a phone number is used, the type can either besms
orphone_change
. If an email address is used, the type can be one of the following:signup
,magiclink
,recovery
,invite
oremail_change
. - The verification type used should be determined based on the corresponding auth method called before
verifyOtp
to sign up or sign in a user.
Parameters
token
REQUIRED
StringThe token that user was sent to their email or mobile phone
type
REQUIRED
OtpTypeType of the OTP to verify
email
Optional
StringEmail address that the OTP was sent to
phone
Optional
StringPhone number that the OTP was sent to
redirectTo
Optional
StringURI to redirect the user to after the OTP is verified
captchaToken
Optional
StringThe captcha token to be used for captcha verification
tokenHash
Optional
StringToken used in an email link
final AuthResponse res = await supabase.auth.verifyOTP(
type: OtpType.sms,
token: '111111',
phone: '+13334445555',
);
final Session? session = res.session;
final User? user = res.user;