|
58 | 58 | - [Passing `StoreOptions`](#passing-storeoptions-9) |
59 | 59 | - [Retrieving an Access Token for a Connection](#retrieving-an-access-token-for-a-connection) |
60 | 60 | - [Passing `StoreOptions`](#passing-storeoptions-10) |
| 61 | +- [Revoking a Refresh Token](#revoking-a-refresh-token) |
| 62 | + - [Revoking the session token](#revoking-the-session-token) |
| 63 | + - [Revoking an explicit token](#revoking-an-explicit-token) |
| 64 | + - [Revoking on logout](#revoking-on-logout) |
61 | 65 | - [Logout](#logout) |
62 | 66 | - [Passing the `returnTo` parameter](#passing-the-returnto-parameter) |
63 | 67 | - [Passing `StoreOptions`](#passing-storeoptions-11) |
@@ -1473,6 +1477,47 @@ Once an enterprise connection has the option enabled, `getSession()` / `getUser( |
1473 | 1477 | - The connection must be an `okta` or `oidc` enterprise connection with `id_token_session_expiry_supported: true` (Dashboard toggle "Use ID Token for Session Expiry", Management API, or Terraform). |
1474 | 1478 | - Authorization Code flow. |
1475 | 1479 |
|
| 1480 | +## Revoking a Refresh Token |
| 1481 | +
|
| 1482 | +Revoking a refresh token invalidates it at Auth0 so it can no longer be used to obtain new access tokens. |
| 1483 | +This is useful when implementing secure logout flows or when a user's session needs to be forcibly terminated. |
| 1484 | +
|
| 1485 | +Revocation requires the application to have been granted `offline_access` scope so Auth0 issues a refresh token, and the target API must have **Allow Offline Access** enabled. |
| 1486 | +
|
| 1487 | +> **Note:** Revocation does not affect access tokens that have already been issued. They remain valid until their expiry. For immediate session termination, combine revocation with `logout()`. |
| 1488 | +
|
| 1489 | +### Revoking the session token |
| 1490 | +
|
| 1491 | +When called without arguments, `revokeRefreshToken()` reads the refresh token directly from the current session: |
| 1492 | +
|
| 1493 | +```ts |
| 1494 | +await serverClient.revokeRefreshToken(); |
| 1495 | +``` |
| 1496 | +
|
| 1497 | +If no session exists or the session has no refresh token, a `MissingSessionError` is thrown. |
| 1498 | +
|
| 1499 | +### Revoking an explicit token |
| 1500 | +
|
| 1501 | +A specific token can be passed via `options.token`, bypassing the session lookup: |
| 1502 | +
|
| 1503 | +```ts |
| 1504 | +await serverClient.revokeRefreshToken({ token: '<refresh_token>' }); |
| 1505 | +``` |
| 1506 | +
|
| 1507 | +In resolver mode, the domain-match guard still applies even when a token is supplied explicitly. If the session domain does not match the domain resolved for the current request (or if the session has no stored domain), the call returns without revoking. Pass an empty string to `options.token` to get a `MissingRequiredArgumentError` rather than a silent no-op. |
| 1508 | +
|
| 1509 | +### Revoking on logout |
| 1510 | +
|
| 1511 | +`logout()` automatically revokes the session's refresh token before clearing the local session. |
| 1512 | +Revocation is best-effort: if it fails for any reason (network error, token already revoked, misconfiguration), logout still proceeds. In resolver mode, both revocation and local session deletion only occur when the stored session domain matches the resolved domain — if they differ, the session belongs to a different tenant and is left untouched. |
| 1513 | +
|
| 1514 | +```ts |
| 1515 | +const logoutUrl = await serverClient.logout({ |
| 1516 | + returnTo: 'http://localhost:3000', |
| 1517 | +}); |
| 1518 | +// Redirect user to logoutUrl |
| 1519 | +``` |
| 1520 | +
|
1476 | 1521 | ## Logout |
1477 | 1522 |
|
1478 | 1523 | Logging out ensures the stored tokens and user information are removed, and that the user is no longer considered logged-in by the SDK. |
|
0 commit comments