tokenRefresh method

Future<VILoginTokens> tokenRefresh(
  1. String username,
  2. String token
)

Performs refresh of access token for the given Voximplant username using refresh token.

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

token - Refresh token can be obtained from VIAuthResult.loginTokens after previous successful login.

Throws VIException, if refresh process failed, otherwise returns new tokens.

Errors:

Implementation

Future<VILoginTokens> tokenRefresh(String username, String token) async {
  try {
    Map<String, dynamic>? data = await _channel
        .invokeMapMethod<String, dynamic>(
            'Client.tokenRefresh', <String, String>{
      'username': username,
      'refreshToken': token,
    });
    if (data == null) {
      _VILog._e('VIClient: tokenRefresh: data was null, skipping');
      throw VIException(
        VIClientError.ERROR_INTERNAL,
        'VIClient:tokenRefresh: data was null',
      );
    }
    VILoginTokens loginTokens = VILoginTokens(
      accessExpire: data['accessExpire'],
      accessToken: data['accessToken'],
      refreshExpire: data['refreshExpire'],
      refreshToken: data['refreshToken'],
    );
    return loginTokens;
  } on PlatformException catch (e) {
    throw VIException(e.code, e.message);
  }
}