updateToken method

Future<bool> updateToken([
  1. num minValidity = 5
])

If the token expires within minValidity seconds the token is refreshed. If the session status iframe is enabled, the session status is also checked. Returns a promise telling if the token was refreshed or not. If the session is not active anymore, the promise is rejected.

@param minValidity Seconds left. (minValidity is optional, if not specified 5 is used) @returns Promise with a boolean indicating if the token was succesfully updated.

Implementation

Future<bool> updateToken([num minValidity = 5]) async {
  // TODO: this is a workaround until the silent refresh (issue #43)
  // is not implemented, avoiding the redirect loop.
  if (this._silentRefresh) {
    var tokenExpired = this.isTokenExpired();
    if (tokenExpired) {
      throw new Exception(
          'Failed to refresh the token, or the session is expired');
    }

    return true;
  }

  return promiseToFuture<bool>(this._keycloak.updateToken(minValidity));
}