What's the correct way to refresh a JWT token? It ...
# ory-network
b
What's the correct way to refresh a JWT token? It seems doing a refetch still expires teh token after 15 mins when using
useSession
from
@ory/elements-react/client
Copy code
useEffect(() => {
    setToken(session?.active ?? false);
  }, [session]);

  // Refresh session periodically
  useEffect(() => {
    // Setup interval to refresh token
    const interval = setInterval(
      () => {
        refetch();
      },
      4 * 60 * 1000,
    );
b
Just to confirm: are you talking about Ory Oauth2 or Ory Identities with sessions? It seems like you're talking about cookie based sessions, which can be very long lived (30 days). You have to fetch the data associated with the session regularly, though as the identity or the session details could've changed.
b
I am using ory identities with sessions.