loginWithAccessToken method

Future<VIAuthResult> loginWithAccessToken(
  1. String username,
  2. String token
)

Logs in a user with the given Voximplant username and access token.

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

token - Access token that was obtained from VIAuthResult.loginTokens after previous successful login.

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

Errors:

Implementation

Future<VIAuthResult> loginWithAccessToken(
  String username,
  String token,
) async {
  _changeClientState(VIClientState.LoggingIn);
  try {
    Map<String, dynamic>? data =
        await _channel.invokeMapMethod<String, dynamic>(
      'Client.loginWithToken',
      <String, String>{'username': username, 'token': token},
    );
    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;
  }
}