loginWithOneTimeKey method

Future<VIAuthResult> loginWithOneTimeKey(
  1. String username,
  2. String hash
)

Logs in a user with the given Voximplant username and one time key that was generated before.

username - Full user name, including Voximplant user, application, and account name in the format user@application.account.voximplant.com.

hash - Hash that was generated using following formula: MD5(oneTimeKey+"|"+MD5(user+":voximplant.com:"+password)).

Throws VIException, if login process failed, otherwise returns VIAuthResult.

Errors:

Implementation

Future<VIAuthResult> loginWithOneTimeKey(String username, String hash) async {
  _changeClientState(VIClientState.LoggingIn);
  try {
    Map<String, dynamic>? data = await _channel
        .invokeMapMethod('Client.loginWithKey', <String, dynamic>{
      'username': username,
      'hash': hash,
    });
    if (data == null) {
      _VILog._e('VIClient: login: data was null, skipping');
      throw VIException(
        VIClientError.ERROR_INTERNAL,
        'VIClient:login: data was null',
      );
    }
    _saveUsername(username);
    return await _processLoginSuccess(data);
  } on PlatformException catch (e) {
    VIClientState state = await getClientState();
    _changeClientState(state);
    throw VIException(e.code, e.message);
  } catch (e) {
    VIClientState state = await getClientState();
    _changeClientState(state);
    rethrow;
  }
}