Authenticate API
Enables you to submit a request with a basic auth header to authenticate a user and retrieve information about the authenticated user.
Request
GET /_security/_authenticate
Description
A successful call returns a JSON structure that shows user information such as their username, the roles that are assigned to the user, any assigned metadata, and information about the realms that authenticated and authorized the user.
Response codes
If the user cannot be authenticated, this API returns a 401 status code.
Examples
To authenticate a user, submit a GET request to the /_security/_authenticate endpoint:
resp = client.security.authenticate() print(resp)
const response = await client.security.authenticate(); console.log(response);
GET /_security/_authenticate
The following example output provides information about the "rdeniro" user:
{
"username": "rdeniro",
"roles": [
"admin"
],
"full_name": null,
"email": null,
"metadata": { },
"enabled": true,
"authentication_realm": {
"name" : "file",
"type" : "file"
},
"lookup_realm": {
"name" : "file",
"type" : "file"
},
"authentication_type": "realm"
}
© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/security-api-authenticate.html