Auth0 Session & Token Management

Auth0 integration patterns showing how sessions, tokens, and device management work across different client types and security requirements.

Follow the demo script →

Foundations — Session & Token Basics

The three demos whose own walkthrough uses the Session Sidebar — cross-app session visibility, SSO sharing, and revocation.

Traditional Web App
Authorization Code Flow with server-side session cookie. Back-Channel Logout propagates revocation to all apps when a session ends. Shows active sessions via the Auth0 Session Management API.
Cookie sessionBack-Channel LogoutSession Management APISession revoke
Open demo →
Backend-for-Frontend
Confidential OAuth client — tokens are stored server-side behind an HttpOnly session cookie and never reach the browser. The browser holds a session cookie; it never sees a bearer token. Multi-Resource Refresh Token (MRRT) exchanges one refresh token for access tokens scoped to multiple API audiences, entirely server-side.
HttpOnly session cookieZero browser token exposureMulti-Resource Refresh TokensPKCE ≠ token storage
Open demo →
High Trust App
SSO isolation via sso:false on the Auth0 client. Logging into any other app on this tenant does not carry over — the Authorization Server always forces fresh credentials. Demonstrates per-application session isolation for high-sensitivity surfaces.
sso:falseNo SSO reuseIsolated AS sessionPer-app auth enforcement
Open demo →
Unified Profile & Session Hub
Management-API-backed profile editing (PATCH /api/v2/users/:id with a user-scoped token) alongside the suite's session hub — the Session Sidebar appears here and on exactly 3 other pages (Traditional, BFF, High Trust), because this page's role as the shared session view is itself part of what it demonstrates. Requires signing into one of those 3 patterns first. Contrast with the My Account API demo's newer, purpose-built self-service surface.
Management APIUser-scoped tokenSession hubContrast with My Account API
Open demo →

Other Client Patterns

Public-client and alternate-validation variations on the same session/token problem — no sidebar here; each page shows its own device list inline.

SPA with DPoP
Public browser client, no server-side session at all. DPoP binds the access token to an ephemeral ES256 key pair generated in IndexedDB — a stolen token is useless without the private key. A Post-Login Action stamps Refresh Token Metadata (device, browser, IP) on the refresh token at issuance.
DPoP token bindingRefresh Token MetadataNo server-side session@auth0/auth0-spa-js
Open demo →
SPA with Online Refresh Tokens
Online Refresh Tokens are validated server-side on every exchange — Auth0 checks the token store rather than just verifying the signature. Revoke a session and the next getTokenSilently() call fails immediately, with no access-token grace period. No DPoP (intentional — isolates ORT from sender constraining).
Immediate revocationServer-side RT validationRevocation speed testNo AT grace period
Open demo →

Session Transfer & SSO

Bridging a session across devices or origins without re-authenticating.

Native-to-Web SSO
Session transfer token bridges a native app session into a web browser session — no password re-entry. Single-use, 60-second expiry, IP-bound. Shows the exact exchange request, raw STT with countdown timer, and both sessions' tokens compared claim-by-claim.
session_transfer_token60s single-useIP-boundClaim diff
Open demo →
Cross-Domain SSO
Two genuinely separate web origins, same Auth0 tenant, default SSO settings — the mirror image of the High Trust App demo. Log into Brand A, then hit Brand B's prompt=none check: Auth0's own AS session cookie silently authenticates the second app with no login screen.
prompt=noneShared AS sessionTwo real originslogin_required handling
Open demo →
Session Delegation
Auth0's new paved path for impersonation-style access: a support agent (actor) mints a Session Transfer Token via Custom Token Exchange, naming a different (subject) user and their own ID token as actor_token. Redeeming it establishes an ephemeral, 2-hour, IP-bound session as that user with an act claim recording the delegating agent — no refresh token, ever. Live tenant log panel shows the real sdel/sdeleacft/sdelsa audit codes.
Custom Token Exchange + actor_tokenact claim (sub_profile, role)Dedicated sdel* log codesNo refresh tokens, ever
Open demo →
Ephemeral Sessions
Auth0's "Manage Sessions with Actions" post-login APIs, applied unconditionally by a dedicated always-ephemeral client rather than a client-asserted "shared device" flag. A Post-Login Action calls api.session.setCookieMode('non-persistent') plus tightened setExpiresAt/setIdleExpiresAt on every login; no offline_access scope means no refresh token is ever minted; this app's own session cookie is independently shortened to match. Session Management API panel shows the real cookie.mode and expiry as ground truth. Compare with Traditional Web App for the persistent-session contrast.
api.session.setCookieMode()setExpiresAt / setIdleExpiresAtNo offline_access — no refresh tokenTwo sessions, both shortened
Open demo →

Token Exchange

RFC 8693 — trading one token for another, preserving or mapping identity.

On-Behalf-Of Token Exchange
RFC 8693 token exchange: a middle-tier service presents the user's access token and receives a new token for a downstream API. The user's sub is preserved end-to-end; the act claim records the delegation chain. Demonstrates the canonical pattern for AI agent and microservice architectures.
RFC 8693act delegation chainIdentity preservationAI agent pattern
Open demo →
Custom Token Exchange
Exchange any external token — JWT, SAML, or arbitrary format — for full Auth0 AT + ID Token + RT. An Auth0 Action validates the incoming token and maps it to an Auth0 user identity with no browser redirect and no Universal Login. Covers external IdP federation, migration, and device attestation.
Any token formatAuth0 Action validatesNo browser redirectExternal IdP federation
Open demo →
Firebase Auth → Auth0: Lazy Migration
The same RFC 8693 Custom Token Exchange mechanism as the demo above, upgraded to a real external IdP: a genuine, Google-issued RS256 Firebase ID token, verified against Google's live JWKS. An existing Firebase-Auth user base gets an Auth0 identity provisioned just-in-time on first exchange — no bulk migration, no forced password reset.
Real Google-issued RS256 tokenLive JWKS verificationemail_verified gatingJust-in-time migration
Open demo →
Google One Tap
Google's One Tap widget rendered directly on this app's own page via FedCM — no redirect to get the credential. The resulting Google ID token is exchanged for Auth0 tokens via the same Custom Token Exchange mechanism as the Firebase demo above. Universal Login has its own native FedCM One Tap toggle too, but it doesn't currently work with Token Vault on the same connection, so it isn't demoed side by side here — the page covers the tradeoff.
FedCM, no redirectReal Google ID tokenRFC 8693 token exchangeUL variant exists — conflicts with Token Vault
Open demo →
Token Vault — Connected Apps
Auth0 Connected Accounts + getAccessTokenForConnection() link Google Calendar and GitHub as secondary connections, independent of the primary login. Two columns compare live results side by side — real-first-fallback means a tester with only one of the two accounts still sees a full comparison, the other column clearly labeled simulated.
Connected AccountsgetAccessTokenForConnection()Real-first-fallbackNo third-party password stored
Open demo →
Token Vault — Organization Isolation
Same Connected Accounts mechanism as Token Vault, with an Auth0 Organization added to the login. Connecting Google or GitHub while authenticated into one org is invisible from another — no admin-provisioned, org-wide connection, just per-user consent partitioned by org_id. Switch orgs to see the same identity with two independent token sets.
Auth0 OrganizationsPer-org_id isolationorganization on login, not on the token callNot admin bulk-provisioning
Open demo →
Cross App Access (XAA)
Auth0's Early Access Identity Assertion Authorization Grant for AI-agent-to-app access. An enterprise IdP issues a short-lived ID-JAG gated by admin policy; Agent0 (Requesting App) redeems it for a Todo0 (Resource App) access token via a real Auth0 jwt-bearer grant — no consent screen, no shared credential. The Enterprise IdP is simulated locally with jose-generated RS256 keys; Todo0 (Resource App) is real Auth0. Requesting App redemption is Auth0-side not-yet-shipped, so that one call attempts real Auth0 first and falls back to a clearly-labeled mock, switching over automatically once Auth0 ships it.
ID-JAGjwt-bearer grantCentralized policy revocationMCP / AI agent pattern
Open demo →

Decoupled & Non-Browser Auth

Authentication that happens away from the requesting device entirely.

CIBA
Client-Initiated Backchannel Authentication — a requesting device sends a real Auth0 Guardian push notification to a separate device for approval, with no redirect and no browser round-trip on the approver's side at all. Requires an Enterprise plan and genuine Guardian enrollment, not a simulated inbox.
Decoupled authReal Guardian pushNo persisted consentEnterprise-only
Open demo →
Device Authorization Grant
RFC 8628 Device Code flow for input-constrained clients — a CLI tool or smart TV displays a code, and the user redeems it via real Universal Login on a second screen. No prior session, no MFA dependency, works on any Auth0 plan. Requires a native/public client — no client secret anywhere in the flow.
RFC 8628Second-screen loginPublic client, no secretAny plan
Open demo →

Identity Bridging

Connecting pre-authentication activity to a known, authenticated identity.

Anonymous to Known
Capture a PostHog anonymous distinct_id before Auth0 login, then call posthog.identify() after callback to merge the pre-auth browsing journey into the authenticated user profile. In-app reporting panel queries the PostHog Events API to show the stitched timeline.
PostHog identify()Anonymous distinct_idPerson mergeEvents API reporting
Open demo →
Auth0 Anonymous Sessions
A first-party client issues a real OAuth access token (sub: anon@xxx) for an unidentified visitor via POST /anonymous/token, called directly from the browser so Auth0 can set its own session cookie. Contrasts a genuinely public catalog endpoint against a JWKS-verified cart endpoint, then hands off to a known user with zero extra code on the redirect.
POST /anonymous/tokenTransparent cookie modeJWKS-verified anon@ tokenPost-Login Action handoff
Open demo →

Organizations & B2B

Multi-tenant login, invitations, and org-scoped access for B2B SaaS.

Organizations — B2B Login
Auth0 Organizations for B2B multi-tenancy: the organization parameter travels on the login request itself, landing as an org_id claim on the session. Covers direct member login into a pre-provisioned org, and the invitation flow — a Management-API-created invitation link that signs up a new user, verifies their email, and assigns org-scoped roles in one Auth0-hosted step, no follow-up API call from this app.
organization on loginInvitation-based signupOrg-scoped rolesorg_id claim
Open demo →
RBAC & Permissions on Access Tokens
A resource server with RBAC and "Add Permissions in the Access Token" enabled mints a real permissions claim on the access token, and this demo's own API routes actually check it before allowing a request — the one place in this suite an authorization decision is made on more than just session presence. The org-context switch shows why tenant-wide and org-scoped role assignments are separate Auth0 objects: the same user's permissions genuinely narrow when authenticated through an Organization with a different role assigned.
permissions claimReal 403 on missing permissionOrg-scoped vs tenant-wide rolesEnable RBAC + Add Permissions toggles
Open demo →

Fine-Grained Authorization

What a token proves versus what it's allowed to do — moving the decision out of the token and into a real ReBAC check at the gateway.

FGA as an API Gateway Enforcement Point
A real Cloudflare Worker gateway in front of a real OpenFGA store — the access token carries no permissions claim at all; every allow/deny decision happens out-of-band, at the gateway, against a live Check call. ReBAC via team membership shows one tuple change can flip access across many resources with zero code change. A gateway outage renders as "unavailable" (503), never a false deny — fail-closed is a real, tested design decision, not just a claim.
OpenFGA Check at the gatewayReBAC via team membershipFail-closed (503 ≠ deny)No permissions claim on the token
Open demo →
Auth0 Identity + Firestore
Surfaces this suite's existing firebase-admin credential (already backing session storage elsewhere) as its own pattern: the Auth0 sub claim used as a stable foreign key into Firestore, for role lookup and an actor-attributed audit trail. No permissions claim on the token and no new Auth0 application — authorization data and history live entirely in Firestore, reached only through the server-side Admin SDK.
sub as Firestore foreign keyRole-gated writesReal actor-attributed audit logNo new Auth0 app
Open demo →

Self-Service Account Management

The user managing their own factors and profile directly, via Auth0's real My Account API.

My Account API — Factor Management
Auth0's real self-service /me/v1/ API, not the Management API with a user-scoped token — driven by Auth0's own official @auth0/universal-components-react UI (<UserMFAManagement />), not hand-rolled WebAuthn/OTP forms. A generic backend proxy mints a narrowly-scoped access token per request via a raw refresh-token exchange, since the Next.js SDK's getAccessToken() cannot mint a token for a different audience than login requested. The real tenant does enforce MFA step-up for an already-enrolled user, and /me/v1/profile has no working self-service scope at all on this tenant — both confirmed live, not assumed.
/me/v1/authentication-methodsOfficial UserMFAManagement componentRaw refresh-token exchangeReal MFA step-up enforcement
Open demo →
Account Linking (Suggested + User-Initiated) & Unlink
Two sanctioned ways to merge identities, plus unlink, all on one dedicated identity isolated from every other demo in this suite (its own Auth0 application, own test identity — not a reuse of the Traditional web app). A Post-Login Action detects a same-email match and signals it via an ID token claim — detection only, nothing linked yet. Suggested and user-initiated linking both share one link-callback implementation: a real second login into the candidate identity, verified server-side, before any Management API write. Unlink is guarded against removing the primary identity or the one behind your current session. An earlier design used Auth0's native suspended-transaction redirect primitives (sendUserTo/encodeToken/the /continue resume endpoint) for the suggested-linking consent screen — abandoned after adversarial review found that re-authenticating mid-suspension risks Auth0 clobbering the suspended transaction.
Post-Login Action claimNo suspended-transaction redirectShared link-callback, both pathsGuarded unlink
Open demo →
Universal Portals — Hosted Self-Service
The companion to My Account API and Organizations above: instead of this app calling those APIs and rendering its own UI, a Universal Portal is a Beta, non-production-only Auth0 feature where Auth0 builds and serves the entire self-service page itself. The backing Regular Web App holds tokens server-side behind its own session, the same never-reaches-the-browser model as the BFF demo. Confirmed live: the dashboard's portal-creation wizard auto-provisions its own backing app with zero API Access or callback/logout URLs configured — every piece of manual setup this suite's other demos needed still applies. Also confirmed live: adding a new passkey 400s on this tenant's canonical *.auth0app.com domain even with correct scopes and WebAuthn enabled — creating a passkey needs a custom domain, since WebAuthn won't bind a new credential to a shared, multi-tenant origin — while viewing and deleting an existing passkey, and TOTP enrollment, all work fine on the canonical domain today.
Hosted, not embeddedMRRT across My Account + My OrganizationWizard-created app ships unconfiguredBeta, non-prod only
Open demo →

Alternate Runtimes

The same flows, on different infrastructure — what actually changes and what doesn't.

Hono on Cloudflare Workers
A real, separately-deployed confidential Auth0 client running on Cloudflare Workers via @auth0/auth0-hono, compared against this suite's Traditional and BFF demos. Same OIDC flow, but a stateless encrypted-cookie session by default (no database) and an edge runtime instead of Node.js serverless — both genuinely different tradeoffs, not just a different host.
@auth0/auth0-honoStateless cookie sessionEdge runtime (Workers)One middleware call
Open demo →
Hono on Deno Deploy
The same @auth0/auth0-hono middleware as the Cloudflare Workers demo, deployed instead to Deno Deploy — a third genuinely different runtime and vendor. Dependencies resolve straight from the npm registry via npm: specifiers, no node_modules or bundler step, and the SDK's Node compatibility needs (async_hooks) work with zero opt-in compatibility flag, unlike Workers' explicit nodejs_compat requirement.
@auth0/auth0-hononpm: specifier resolutionDeno Deploy isolateNo compat flag needed
Open demo →
Firebase Hosting — SPA Client
A public Auth0 client (Authorization Code + PKCE) via @auth0/auth0-spa-js, deployed as plain static files to classic Firebase Hosting — no build step, no server-side code at all. Unlike the Hono siblings, which vary the hosting platform while keeping the same confidential-client shape as Traditional/BFF, this demo varies the client type itself: tokens live in browser memory only, and there is no server-side session of any kind to revoke.
@auth0/auth0-spa-jsPublic client (PKCE)Zero server-side codeTokens in memory only
Open demo →

Security Controls

Automated detection and response controls layered on top of the base auth flow — including a deliberately naive one, and why it fails.

AiTM Detector
A Post-Login Action denies a login and revokes sessions/refresh tokens on a simulated hostname-mismatch signal — modeled on PingOne's AiTM predictor response. The original design called for a real client-side probe reading window.location.hostname on the Universal Login page; a spike against this tenant found that channel doesn't work as intended on New Universal Login, so this demo simulates the signal via a server-side query parameter instead. Either way, the honest point stands: Evilginx is a full inline reverse proxy that can strip, rewrite, or spoof a real client-reported signal the same way it already harvests credentials, so this demonstrates the automated response to a detection, not a working anti-phishing control. The real answer — origin-bound credentials — is what WebAuthn/passkeys provide instead.
Simulated hostname mismatchPost-Login ActionAutomated session revocationNaive by design — see page for why this signal isn't actually robust against Evilginx
Open demo →