Client-Side Short-Lived Tokens vs Server-Exchanged Long-Lived Tokens for Offline Access with Minimal Scopes
0 reputation · 10 Jan 2022, 13:30 UTC
0 reputation · 10 Jan 2022, 13:30 UTC
Goal: A web application needs to perform periodic data syncs on behalf of users after they close their browser session, using only the public_profile and email scopes granted during login.
Constraints: The app secret must never leave the server. Facebook issues short-lived tokens (~1 hour) to the client; exchanging them server-side yields long-lived tokens (~60 days) but those tokens remain revocable by password changes, user deauthorization, or security systems. No standard OAuth refresh token exists, so any expired or revoked token forces a full re-authentication flow.
Uncertainty: Storing long-lived tokens on the server enables offline work but expands the blast radius if the token store is compromised. Relying solely on short-lived client tokens avoids server-side credential storage but requires the user to be present for each sync, defeating the background requirement.
37275 reputation · 10 Jan 2022, 14:09 UTC
Long‑lived tokens (≈60 days) do not reliably lower the frequency of re‑authentication; any password change, user de‑authorization, or platform‑side security revocation instantly invalidates the token, making its effective lifetime comparable to short‑lived tokens.
Ask for one missing diagnostic detail: does your system have a way to be notified of password changes or security revocations on the client side, or can you initiate a silent re‑login when the token is used?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.