signInWithPhone method
Logs in an existing user using their phone number and password.
phone
is the user's phone number WITH international prefix
password
is the password of the user
Implementation
Future<GotrueSessionResponse> signInWithPhone(
String phone, [
String? password,
]) async {
try {
final body = {'phone': phone, 'password': password};
final fetchOptions = FetchOptions(headers);
const queryString = '?grant_type=password';
final response = await _fetch.post(
'$url/token$queryString',
body,
options: fetchOptions,
);
if (response.error != null) {
return GotrueSessionResponse.fromResponse(response: response);
} else {
final session =
Session.fromJson(response.rawData as Map<String, dynamic>);
return GotrueSessionResponse.fromResponse(
response: response,
data: session,
);
}
} catch (e) {
return GotrueSessionResponse(error: GotrueError(e.toString()));
}
}