updateTokens method

void updateTokens(
  1. RefreshResponse refreshResponse
)

Updates the underlying JWTs with those from the given RefreshResponse.

if (session.sessionToken.isExpired) {
  final refreshResponse = await Descope.auth.refreshSession(session.refreshJwt);
  session.updateTokens(refreshResponse);
}

Important: It's recommended to use a DescopeSessionManager to manage sessions, in which case you should call updateTokens on the manager itself, or just call refreshSessionIfNeeded to do everything for you.

Implementation

void updateTokens(RefreshResponse refreshResponse) {
  _sessionToken = refreshResponse.sessionToken;
  _refreshToken = refreshResponse.refreshToken ?? _refreshToken;
}