Token Revocation¶
Revoking access tokens¶
After issuing an access token, a user or an admin can revoke it in case of theft or a security violation. You can do this by calling the Revoke API using a utility like cURL. The Revoke API's endpoint URL is http://localhost:8280/revoke
.
Note
You can also revoke refresh tokens. For more information, see Revoking a refresh token.
The parameters required to invoke the following API are as follows:
-
token
- The token to be revoked -
<base64 encoded (clientId:clientSecret)>
- Use a base64 encoder to encode your client ID and client secret using the following format. MWARE does not recommend the use of online base64 encoders for this purpose.<clientId>:<clientSecret>
Thereafter, enter the encoded value for this parameter. -
token_type_hint
= This parameter is optional. If you do not specify this parameter, then MWARE IAM (MWARE IAM) will search in both key spaces (access and refresh) and if it finds a matching token then it will be revoked. Therefore, if this parameter it not specified the token revocation process takes longer. However, if you specify this parameter then MWARE IAM only searches in the respective token key space, hence the token revocation process is much faster.curl -k -v -d "token=<ACCESS_TOKEN_TO_BE_REVOKED>" -H "Authorization: Basic <base64 encoded (clientId:clientSecret)>" -H "Content-Type: application/x-www-form-urlencoded" https://localhost:9443/oauth2/revoke curl -k -v -d "token=<ACCESS_TOKEN_TO_BE_REVOKED>&token_type_hint=<access_token_or_refresh_token>" -H "Authorization: Basic <base64 encoded (clientId:clientSecret)>" -H "Content-Type: application/x-www-form-urlencoded" https://localhost:9443/oauth2/revoke
curl -k -v -d "token=a0d210c7a3de7d548e03f1986e9a5c39" -H "Authorization: Basic OVRRNVJLZWFhVGZGeUpRSkRzam9aZmp4UkhjYTpDZnJ3ZXRual9ZOTdSSzFTZWlWQWx1aXdVVmth" -H "Content-Type: application/x-www-form-urlencoded" https://localhost:9443/oauth2/revoke curl -k -v -d "token=1d18ec65-6151-3499-9352-68afe64299c3&token_type_hint=access_token" -H "Authorization: Basic OVRRNVJLZWFhVGZGeUpRSkRzam9aZmp4UkhjYTpDZnJ3ZXRual9ZOTdSSzFTZWlWQWx1aXdVVmth" -H "Content-Type: application/x-www-form-urlencoded" https://localhost:9443/oauth2/revoke curl -k -v -d "token=eyJ0eXAiOiJKV1QiLCJhbGciOi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o6K-ITmO2m0SyCOrzo5PWMYbeZpkKM9slWahrGJm18XqGu7aRZiEnN8cLCke-DsnQVJJcCaS_jTniAD_-DCk5VBUTdQP1yiekq-A5QjKp_dKAjMF-8PQPXpMU526fXMMauFTz65EEZ-BpwAvfSBwLnSGI1GQp7xF9VWytCBAWt4ZvK6e7Y6hrwH1p7KT4Nli6PZv6RxbalW0mI9vqknSJRhWtn0GQcw1FSymMi-QOo0M7LgwIp7ypuw" -H "Authorization: Basic OVRRNVJLZWFhVGZGeUpRSkRzam9aZmp4UkhjYTpDZnJ3ZXRual9ZOTdSSzFTZWlWQWx1aXdVVmth" -H "Content-Type: application/x-www-form-urlencoded" https://localhost:9443/oauth2/revoke
You receive an empty response with the HTTP status as 200. The following HTTP headers are returned: RevokedRefreshToken: 5e87a8235cd4d066e15c4c989f5ecf94 Cache-Control: no-store Access-Control-Allow-Methods: POST X-Content-Type-Options: nosniff AuthorizedUser: admin@carbon.super Pragma: no-cache RevokedAccessToken: a0d210c7a3de7d548e03f1986e9a5c39 X-XSS-Protection: 1; mode=block Access-Control-Allow-Headers: authorization,Access-Control-Allow-Origin,Content-Type,SOAPAction,Authorization Content-Type: text/html Date: Thu, 07 Nov 2019 07:51:46 GMT Transfer-Encoding: chunked Note that if you use an invalid access token, you still receive an empty response with the HTTP status as 200 but only the following HTTP headers are returned: Cache-Control: no-store Access-Control-Allow-Methods: POST X-Content-Type-Options: nosniff Pragma: no-cache X-XSS-Protection: 1; mode=block Access-Control-Allow-Headers: authorization,Access-Control-Allow-Origin,Content-Type,SOAPAction,Authorization Content-Type: text/html Date: Thu, 07 Nov 2019 07:58:11 GMT Transfer-Encoding: chunked
Revoking access tokens obtained with a JWT grant
If you obtained an access token with the JWT grant type, you do not have to provide the client secret to revoke it. The sample cURL command to revoke an access token with JWT grant is given below.
curl -X POST -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" -d "token=<ACCESS_TOKEN_TO_BE_REVOKED>&token_type_hint=access_token&client_id=<CLIENT_ID>" http://localhost:8243/revoke