11[role="xpack"]
22[[security-api-invalidate-token]]
3- === Delete token API
3+ === Invalidate token API
44
5- Invalidates a bearer token for access without requiring basic authentication .
5+ Invalidates an access token or a refresh token .
66
77==== Request
88
99`DELETE /_xpack/security/oauth2/token`
1010
1111==== Description
1212
13- The tokens returned by the <<security-api-get-token,get token API>> have a
13+ The access tokens returned by the <<security-api-get-token,get token API>> have a
1414finite period of time for which they are valid and after that time period, they
1515can no longer be used. That time period is defined by the
1616`xpack.security.authc.token.timeout` setting. For more information, see
1717<<token-service-settings>>.
1818
19- If you want to invalidate a token immediately, use this delete token API.
19+ The refresh tokens returned by the <<security-api-get-token,get token API>> are
20+ only valid for 24 hours. They can also be used exactly once.
21+
22+ If you want to invalidate an access or refresh token immediately, use this invalidate token API.
2023
2124
2225==== Request Body
2326
2427The following parameters can be specified in the body of a DELETE request and
25- pertain to deleting a token:
28+ pertain to invalidating a token:
29+
30+ `token` (optional)::
31+ (string) An access token. This parameter cannot be used when `refresh_token` is used.
32+
33+ `refresh_token` (optional)::
34+ (string) A refresh token. This parameter cannot be used when `token` is used.
2635
27- `token` (required)::
28- (string) An access token.
36+ NOTE: One of `token` or `refresh_token` parameters is required.
2937
3038==== Examples
3139
@@ -40,6 +48,17 @@ DELETE /_xpack/security/oauth2/token
4048--------------------------------------------------
4149// NOTCONSOLE
4250
51+ whereas the following example invalidates the specified refresh token immediately:
52+
53+ [source,js]
54+ --------------------------------------------------
55+ DELETE /_xpack/security/oauth2/token
56+ {
57+ "refresh_token" : "movUJjPGRRC0PQ7+NW0eag"
58+ }
59+ --------------------------------------------------
60+ // NOTCONSOLE
61+
4362A successful call returns a JSON structure that indicates whether the token
4463has already been invalidated.
4564
0 commit comments