2018-08-18 01:22:09 -04:00
|
|
|
[role="xpack"]
|
|
|
|
[[security-api-invalidate-token]]
|
2018-11-21 02:32:56 -05:00
|
|
|
=== Invalidate token API
|
2018-08-18 01:22:09 -04:00
|
|
|
|
2018-11-21 02:32:56 -05:00
|
|
|
Invalidates an access token or a refresh token.
|
2018-08-18 01:22:09 -04:00
|
|
|
|
|
|
|
==== Request
|
|
|
|
|
|
|
|
`DELETE /_xpack/security/oauth2/token`
|
|
|
|
|
|
|
|
==== Description
|
|
|
|
|
2018-11-21 02:32:56 -05:00
|
|
|
The access tokens returned by the <<security-api-get-token,get token API>> have a
|
2018-08-18 01:22:09 -04:00
|
|
|
finite period of time for which they are valid and after that time period, they
|
|
|
|
can no longer be used. That time period is defined by the
|
|
|
|
`xpack.security.authc.token.timeout` setting. For more information, see
|
|
|
|
<<token-service-settings>>.
|
|
|
|
|
2018-11-21 02:32:56 -05:00
|
|
|
The refresh tokens returned by the <<security-api-get-token,get token API>> are
|
|
|
|
only valid for 24 hours. They can also be used exactly once.
|
|
|
|
|
|
|
|
If you want to invalidate an access or refresh token immediately, use this invalidate token API.
|
2018-08-18 01:22:09 -04:00
|
|
|
|
|
|
|
|
|
|
|
==== Request Body
|
|
|
|
|
|
|
|
The following parameters can be specified in the body of a DELETE request and
|
2018-11-21 02:32:56 -05:00
|
|
|
pertain to invalidating a token:
|
|
|
|
|
|
|
|
`token` (optional)::
|
|
|
|
(string) An access token. This parameter cannot be used when `refresh_token` is used.
|
|
|
|
|
|
|
|
`refresh_token` (optional)::
|
|
|
|
(string) A refresh token. This parameter cannot be used when `token` is used.
|
2018-08-18 01:22:09 -04:00
|
|
|
|
2018-11-21 02:32:56 -05:00
|
|
|
NOTE: One of `token` or `refresh_token` parameters is required.
|
2018-08-18 01:22:09 -04:00
|
|
|
|
|
|
|
==== Examples
|
|
|
|
|
|
|
|
The following example invalidates the specified token immediately:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
DELETE /_xpack/security/oauth2/token
|
|
|
|
{
|
|
|
|
"token" : "dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ=="
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// NOTCONSOLE
|
|
|
|
|
2018-11-21 02:32:56 -05:00
|
|
|
whereas the following example invalidates the specified refresh token immediately:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
DELETE /_xpack/security/oauth2/token
|
|
|
|
{
|
|
|
|
"refresh_token" : "movUJjPGRRC0PQ7+NW0eag"
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// NOTCONSOLE
|
|
|
|
|
2018-08-18 01:22:09 -04:00
|
|
|
A successful call returns a JSON structure that indicates whether the token
|
|
|
|
has already been invalidated.
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"created" : true <1>
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// NOTCONSOLE
|
|
|
|
|
|
|
|
<1> When a token has already been invalidated, `created` is set to false.
|