refreshSession method

Future<AuthResponse> refreshSession([
  1. String? refreshToken
])

Returns a new session, regardless of expiry status. Takes in an optional current session. If not passed in, then refreshSession() will attempt to retrieve it from getSession(). If the current session's refresh token is invalid, an error will be thrown.

Implementation

Future<AuthResponse> refreshSession([String? refreshToken]) async {
  if (currentSession?.accessToken == null) {
    throw AuthException('Not logged in.');
  }

  final currentSessionRefreshToken =
      refreshToken ?? _currentSession?.refreshToken;

  if (currentSessionRefreshToken == null) {
    throw AuthSessionMissingException();
  }

  return await _callRefreshToken(currentSessionRefreshToken);
}