Token revocation

Revocation endpoints invalidate access and refresh tokens upon client request. They are commonly part of the authorization endpoint.

# Initial setup
from your_validator import your_validator
server = WebApplicationServer(your_validator)

# Token revocation
uri = 'https://example.com/revoke_token'
headers, body, http_method = {}, 'token=sldafh309sdf', 'POST'

headers, body, status = server.create_revocation_response(uri,
    headers=headers, body=body, http_method=http_method)

from your_framework import http_response
http_response(body, status=status, headers=headers)
class oauthlib.oauth2.RevocationEndpoint(request_validator, supported_token_types=None, enable_jsonp=False)[source]

Token revocation endpoint.

Endpoint used by authenticated clients to revoke access and refresh tokens. Commonly this will be part of the Authorization Endpoint.

create_revocation_response(endpoint, uri, *args, **kwargs)[source]

Revoke supplied access or refresh token.

The authorization server responds with HTTP status code 200 if the token has been revoked sucessfully or if the client submitted an invalid token.

Note: invalid tokens do not cause an error response since the client cannot handle such an error in a reasonable way. Moreover, the purpose of the revocation request, invalidating the particular token, is already achieved.

The content of the response body is ignored by the client as all necessary information is conveyed in the response code.

An invalid token type hint value is ignored by the authorization server and does not influence the revocation response.

validate_revocation_request(request)[source]

Ensure the request is valid.

The client constructs the request by including the following parameters using the “application/x-www-form-urlencoded” format in the HTTP request entity-body:

token (REQUIRED). The token that the client wants to get revoked.

token_type_hint (OPTIONAL). A hint about the type of the token submitted for revocation. Clients MAY pass this parameter in order to help the authorization server to optimize the token lookup. If the server is unable to locate the token using the given hint, it MUST extend its search accross all of its supported token types. An authorization server MAY ignore this parameter, particularly if it is able to detect the token type automatically. This specification defines two such values:

  • access_token: An Access Token as defined in [RFC6749],
    section 1.4
  • refresh_token: A Refresh Token as defined in [RFC6749],
    section 1.5

Specific implementations, profiles, and extensions of this specification MAY define other values for this parameter using the registry defined in Section 4.1.2.

The client also includes its authentication credentials as described in Section 2.3. of [RFC6749].