delete-tokens.asciidoc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. [role="xpack"]
  2. [[security-api-invalidate-token]]
  3. === Delete token API
  4. Invalidates a bearer token for access without requiring basic authentication.
  5. ==== Request
  6. `DELETE /_xpack/security/oauth2/token`
  7. ==== Description
  8. The tokens returned by the <<security-api-get-token,get token API>> have a
  9. finite period of time for which they are valid and after that time period, they
  10. can no longer be used. That time period is defined by the
  11. `xpack.security.authc.token.timeout` setting. For more information, see
  12. <<token-service-settings>>.
  13. If you want to invalidate a token immediately, use this delete token API.
  14. ==== Request Body
  15. The following parameters can be specified in the body of a DELETE request and
  16. pertain to deleting a token:
  17. `token` (required)::
  18. (string) An access token.
  19. ==== Examples
  20. The following example invalidates the specified token immediately:
  21. [source,js]
  22. --------------------------------------------------
  23. DELETE /_xpack/security/oauth2/token
  24. {
  25. "token" : "dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ=="
  26. }
  27. --------------------------------------------------
  28. // NOTCONSOLE
  29. A successful call returns a JSON structure that indicates whether the token
  30. has already been invalidated.
  31. [source,js]
  32. --------------------------------------------------
  33. {
  34. "created" : true <1>
  35. }
  36. --------------------------------------------------
  37. // NOTCONSOLE
  38. <1> When a token has already been invalidated, `created` is set to false.