verifyOTP method

Future<GotrueSessionResponse> verifyOTP(
  1. String phone,
  2. String token, {
  3. AuthOptions? options,
})

Log in a user given a User supplied OTP received via mobile.

phone is the user's phone number WITH international prefix

token is the token that user was sent to their mobile phone

Implementation

Future<GotrueSessionResponse> verifyOTP(
  String phone,
  String token, {
  AuthOptions? options,
}) async {
  _removeSession();

  final response = await api.verifyMobileOTP(phone, token, options: options);

  if (response.error != null) return response;

  if (response.data?.accessToken != null) {
    _saveSession(response.data!);
    _notifyAllSubscribers(AuthChangeEvent.signedIn);
  }

  return response;
}