refreshAccessToken method

Future<AuthToken> refreshAccessToken ()

Requests access-token from m4e using existing refresh-token

Throws ServerException if call to server fails

Throws ServerException with NO_INTERNET_CONNECTION error

code device is not connected to the internet

Implementation

Future<AuthToken> refreshAccessToken() async {
  if ((await _connectionChecker.hasConnection) ?? false) {
    try {
      final _existingToken = await _authApi.getAuthTokenFromCache();

      final _token = await _authApi.refreshAccessToken(_existingToken);

      // cache new token
      await _authApi.cacheAuthToken(_token);

      return _token;
    } catch (e) {
      rethrow;
    }
  }

  throw ExceptionMessages.kNoInternetConnectionException;
}