- In the Dashboard
- Post a request to the Authentication API
/oauth/revoke
endpoint - Post a request to the
/api/v2/device-credentials
endpoint
Refresh tokens and grants
A grant provides an application with access to a resource on another entity without exposing user credentials. Tokens are issued in the context of a grant, and when a grant is revoked, so are all tokens issued in the context of that grant. When, on the other hand, a token is revoked, this does not necessarily mean that the grant is revoked. You can choose the revocation behavior in the Dashboard tenant settings when a device is unlinked from a user in Auth0, using either the Dashboard or the Management API.For existing tenants, this feature is enabled by default to preserve the existing behavior. For new tenants (as of 13 January 2021), this feature is disabled by default to ensure that the revocation of a refresh token will not revoke the grant. If a grant revocation is needed, a separate request must be sent using a grant revocation endpoint.
- Go to Dashboard > Tenant Settings > Advanced and scroll to the Settings section.
-
Enable or disable the Refresh Token Revocation Deletes Grant toggle depending on how you want the revocation to work.
- Enable the toggle to delete the underlying grant when you revoke the refresh token. Each revocation request invalidates not only the specific token but all other tokens based on the same authorization grant. This means that all refresh tokens that have been issued for the same user, application, and audience will be revoked.
- Disable the toggle to retain the underlying grant when you revoke the refresh token. When a device is unlinked, only the associated refresh token is revoked, leaving the grant intact.
Use the Dashboard
You can use the Dashboard to revoke a user’s authorized access to the application that issued the token. This renders the refresh token invalid, which is functionally identical to revoking the token itself.- Go to Dashboard > User Management > Users, and click the name of the user to view.
- Select the Authorized Applications tab. This page lists all the applications to which the user has authorized access.
- To revoke the user’s access to an authorized application, and hence invalidate the refresh token, click Revoke.
Use the Authentication API
To revoke a refresh token, send aPOST
request to https://{yourDomain}/oauth/revoke
.
The /oauth/revoke
endpoint revokes the entire grant, not just a specific token. Use the /api/v2/device-credentials
endpoint to revoke refresh tokens. The API first validates the application credentials and then verifies whether the token was issued to the application making the revocation request. If this validation fails, the request is refused, and the application is informed of the error. Next, the API invalidates the token. The invalidation takes place immediately, and the token cannot be used again after the revocation. Each revocation request invalidates all the tokens that have been issued for the same authorization grant.
Attribute | Description |
---|---|
client_id Required | Your application’s Client ID. The application should match the one the Refresh Token was issued for. |
client_secret | Your application’s Client Secret. Required for confidential applications. |
token Required | The Refresh Token you want to revoke. |
Revoke tokens without the client secret
For applications that cannot keep the safe (such as native apps), the/oauth/revoke
endpoint supports access without the client secret. However, the application itself must have the property tokenEndpointAuthMethod
set to none
. You can change the tokenEndpointAuthMethod
value, either from the Dashboard > Applications > Applications, or using the Management API.
If the request is valid, the refresh token is revoked, and the response is HTTP 200
, with an empty response body. Otherwise, the response body contains the error code and description.
HTTP Status | Description |
---|---|
200 | The Refresh Token is revoked, does not exist, or was not issued to the application making the revocation request. The response body is empty. |
400 | The required parameters were not sent in the request (“error”: “invalid_request” ). |
401 | The request is not authorized (“error”: “invalid_client” ). Check that the application credentials (client_id and client_secret ) are present in the request and hold valid values. |
Use the Management API
To revoke a refresh token using the Auth0 Management API, you need theid
of the refresh token you wish to revoke. To obtain a list of existing refresh tokens, call the /api/v2/device-credentials
endpoint, specifying type=refresh_token
and user_id
with an access token containing read:device_credentials
scope. To narrow the results, you can also specify the client_id
associated with the token (if known).
/api/v2/device-credentials
endpoint with an access token containing delete:device_credentials
scope and the value of ID obtained above:
HTTP 204: The credential no longer exists.
Considerations and limitations
With the Device Authorization Flow, the only way to force a device to reauthorize is to revoke the refresh token assigned to the device. See Unlink Devices from Users for details. The device will not be forced to reauthorize until the current access token expires and the application tries to use the revoked refresh token. When using Refresh Token Rotation, if a previously invalidated token is used, the entire set of refresh tokens issued since that invalidated token was issued will immediately be revoked, requiring the end-user to re-authenticate.- Use the Authentication API
/oauth/revoke
endpoint to revoke a refresh token. This endpoint does not delete the underlying grant. You can change this behavior to also delete the underlying grant in the Dashboard: Dashboard > Tenant Settings > Advanced. Scroll to Settings and enable the Refresh Token Revocation Deletes Grant toggle. - Use the Management API
/api/v2/device-credentials
endpoint to revoke refresh tokens configured for rotation.