OAuth token revocation: invalidate tokens during logout or unlinking
Learn how to submit an OAuth revocation request, what a successful response means, and why access-token denial may not be immediate across resource servers.
OAuth token revocation: invalidate tokens during logout or unlinking
OAuth token revocation is the procedure by which a client tells the authorization server that an access token or refresh token is no longer needed and should not be used. Common cases include logout, unlinking an app, switching accounts or removing an app. A successful revocation response does not mean every server will immediately reject an existing access token. Token format and the resource server's validation and caching design also matter.
How does the revocation endpoint work?
RFC 7009 defines an authorization-server revocation endpoint that clients call with HTTP POST. The request must use HTTPS and an application/x-www-form-urlencoded body. token_type_hint, such as access_token or refresh_token, is optional. If the token is not found using the hint, the server must check all token types it supports. Find the endpoint through the provider's documentation or trusted OAuth metadata.
POST /revoke HTTP/1.1
Host: auth.example
Content-Type: application/x-www-form-urlencoded
Authorization: Basic <client authentication credentials, if applicable>
token=<token_to_revoke>&token_type_hint=refresh_tokenThe address and values are illustrative. The actual endpoint and authentication method vary by provider. Do not put client secrets or tokens in frontend code, URLs, logs or analytics tools. A public client cannot keep a secret inside its app, so check the provider's documentation for the supported authentication method for that client type.
What does a successful response mean?
Under RFC 7009, the server returns HTTP 200 both when a token is successfully revoked and when the request contains a token that is already invalid. Revoking an already-invalid token also achieves the goal, so the response does not tell the client whether the token was live beforehand. After a success response, the client should not reuse the token and should delete its local copy.
Whether revoking a token also cancels other tokens issued under the same authorization grant depends on server policy. RFC 7009 recommends that revoking a refresh token also invalidate access tokens issued from that grant, but access-token revocation support is optional for servers. Before revocation, users may need to check whether the app is linked to other devices or services and unlink those connections separately.
If an existing access token still works
If an access token is a self-validating signed token and the resource server checks only the signing key and expiration information from issuance, it may not know that the authorization server revoked it. RFC 7009 explains that immediate access-token revocation is difficult without communication between the authorization and resource servers. Deployments that need an immediate block can consider checking current status with introspection on each request or with a limited cache, or sending revocation events to resource servers. Short-lived access tokens limit the revocation window, but do not prevent use during that window.
| Goal | Method and trade-off |
|---|---|
| Remove permission for an app no longer in use | Revoke the refresh token and check the server's policy for tokens issued under that grant. Whether related access tokens are also revoked depends on implementation. |
| Block API access immediately after logout | Find out how the resource server learns about revocation. Central status checks can apply it quickly, but affect request latency and authorization-server availability. |
| Simplify validation and reduce status-query load | Short-lived access tokens may help. They can remain valid until expiry, so they may not meet an immediate-block requirement. |
| Log out from every device or session | Check whether the provider offers separate session or grant revocation. Do not assume revoking one token ends all app sessions. |
Safe logout and unlinking sequence
Locate the refresh and access tokens currently used by the app. Do not copy user-provided tokens into logs.
Confirm the trusted HTTPS revocation endpoint and client-authentication requirements in the provider's documentation.
Send the token in the POST body, with the appropriate optional `token_type_hint` and client authentication if required.
When the server returns HTTP 200, do not use the token again and delete the local copy. Because 200 can also mean the token was already invalid, do not treat it as a reason to keep using the old token.
Treat a timeout or 503 as uncertain: revocation may not have completed. Respect the provider's `Retry-After` if present and design safe retry handling. Keep the user logged out locally and do not use the old credential in new requests while retrying.
If you need to confirm that an API rejects the token, use a non-sensitive resource in a test environment. A 200 from the revocation endpoint alone does not prove immediate denial by every resource server.
Summary
Token revocation is the standard way for a client to tell the authorization server that an OAuth credential is no longer needed. HTTP 200 indicates that the token was revoked or was already invalid; it does not reveal whether the token was live beforehand. Immediate denial of an access token depends on token structure and how resource servers check and cache status. Design for the required logout behavior, including revocation delay and session handling.
References
[RFC 7009 — OAuth 2.0 Token Revocation](https://www.rfc-editor.org/rfc/rfc7009.html)
[RFC 7662 — OAuth 2.0 Token Introspection](https://www.rfc-editor.org/rfc/rfc7662.html)
[RFC 9700 §2.2.2 — Refresh Tokens](https://www.rfc-editor.org/rfc/rfc9700.html#section-2.2.2)