verifyOtp method
Signs in a user using a one-time password (OTP) received via email or other methods.
Example (after user receives OTP):
try {
// First, you might have requested an OTP, e.g., via _supabaseClient.auth.signInWithOtp
// For this example, assume OTP was sent and received by the user.
final response = await authManager.signInWithOtp(
email: 'user@example.com',
token: '123456', // The OTP token entered by the user
);
if (response.user != null) {
print('OTP Sign-in successful for user: \${response.user!.id}');
}
} on AuthException catch (e) {
print('OTP Sign-in error: \${e.message}');
}
Implementation
Future<AuthResponse> verifyOtp({
String? email,
String? phone,
String? token,
required OtpType type,
String? redirectTo,
String? captchaToken,
String? tokenHash,
}) {
// Note: Supabase uses verifyOTP for this flow after an initial signInWithOtp call
// that sends the token. This method assumes the token has been sent and is being verified.
return _supabaseClient.auth.verifyOTP(
email: email,
phone: phone,
token: token,
type: type,
redirectTo: redirectTo,
captchaToken: captchaToken,
tokenHash: tokenHash,
);
}