Revoke tokens for a user

post

/oam/services/rest/consent/revoke

The REST API enables Administrator to invalidate Access or Refresh Tokens issued for a user or a user+client+resource server combination via Authorization code flow (three legged OAuth flow). The API returns all the updated consents for the provided combination. Tokens can also be revoked by giving a specific timestamp.

Request

Supported Media Types
Header Parameters
Form Parameters
  • OAuth Client ID/Identifier. If provided, you must specify the resServerId to uniquely identify the client.
  • OAuth Application ID/Identifier. Required to uniquiely identify client entity, resServerId is mandatory if clientIdentifier is provided.
  • entity to be revoked. Possible values are - ACCESS_TOKENS, REFRESH_TOKENS, TOKENS
    Default Value: TOKENS
  • all tokens issued before this timestamp will be invalidated. timestamp needs to be in the following format yyyy-MM-dd'T'HH:mm:ssZ format. 'Z' is Time offsets from UTC.
    For example
    Feb 20 09:45:51 UTC 2021 --> 2021-02-20T09:45:51Z
    Mar 04 00:39:12 PST 2021 --> 2021-03-04T00:39:12-0800
  • User name/identifier. Name of the user whos grant/consent was used to create tokens.
Back to Top

Response

Supported Media Types

200 Response

Sucessfully updated user consent with revoke details
Body ()
Root Schema : consentAfterRevoke
Type: array
Array of user consent
Show Source
Nested Schema : consentAfterRevoke
Type: object
Show Source
Nested Schema : scope
Type: array
Show Source
Example:
[
    "DemoResServer.DefaultScope"
]

400 Response

Failed to retrieve user consent - detail
Body ()
Root Schema : schema
Type: object
Show Source
Example:
{
    "error":"400",
    "error_description":"Required parameter 'X-OAUTH-IDENTITY-DOMAIN-NAME' is not present."
}
Back to Top

Examples

cURL Sample Request

This example demonstrates a sample request to revoke all Refresh Tokens for a user based on Timestamp

curl --location --request POST '<AdminServerHost>:<AdminServerPort>/oam/services/rest/consent/revoke' \
--header 'Authorization: Basic d2VibG9naWM6d2VsY29tZTE=' \
--header 'x-oauth-identity-domain-name: DemoDomain' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: JSESSIONID=NysahaoNLyc13HzjEh93gJmwbY4HnMetJQY33RE8_ZdBpzpw7kdr!-472705583' \
--data-urlencode 'userId=UserA' \
--data-urlencode 'revoke_type=REFRESH_TOKENS' \
--data-urlencode 'timestamp=2021-03-09T15:30:33+0800'

cURL Sample Response

{
    "consents": [
        {
            "clientId": "DemoClientId",
            "consentId": "30650989-8e53-3010-b06a-98b0ef42b65d",
            "createTimeStamp": "Fri Mar 12 03:55:31 PST 2021",
            "resourceId": "66ac1a16-ee37-4525-81f6-9062d69a743c",
            "scopes": [
                "DemoResServer.DefaultScope"
            ],
            "tokenRevokeTimestamp": "REFRESH_TOKENS=2021-03-08T03:56:49-0800",
            "valid": true
        }
    ]
}
Back to Top