loginWithPassword method

Future<AuthToken> loginWithPassword({
  1. required String password,
  2. String? email,
  3. String? phoneNumber,
  4. List<ScopeValue>? scope,
})

Login an user by providing an identifier (email or phoneNumber) and a password

Implementation

Future<AuthToken> loginWithPassword({
  required String password,
  String? email,
  String? phoneNumber,
  List<ScopeValue>? scope,
}) async {
  try {
    final authTokenInterface = await _platform.loginWithPassword(
      reachFiveKey: ReachFiveKeyConverter.toInterface(reachFiveKey),
      password: password,
      email: email,
      phoneNumber: phoneNumber,
      scope: scope?.map(ScopeValueConverter.toInterface).toList(),
    );

    final authToken = AuthTokenConverter.fromInterface(authTokenInterface);

    return authToken;
  } catch (error, stackTrace) {
    try {
      _platform.parseError(error, stackTrace);
    } catch (interfaceError, interfaceStackTrace) {
      adaptErrors(
        error: interfaceError,
        stackTrace: interfaceStackTrace,
      );
    }
  }
}