initialize method

dynamic initialize()

Implementation

initialize() async {
  _checkConfiguration();

  var jwtToken = await _jwtAuthStorage.getJwtToken();

  if (jwtToken == null) {
    _cleanToken();
    return;
  }

  if (jwtToken.isAccessTokenExpired()) {
    if (jwtToken.isRefreshTokenExpired()) {
      _cleanToken();
      return;
    }

    try {
      jwtToken = await _jwtAuthApiClient.refreshToken(
          jwtToken.username, jwtToken.refreshToken);
    } catch (e) {
      _cleanToken();
      return;
    }
  }

  _setToken(jwtToken);
}