[[reference-security-authenticate]]

////////
===========================================================================================================================
||                                                                                                                       ||
||                                                                                                                       ||
||                                                                                                                       ||
||        ██████╗ ███████╗ █████╗ ██████╗ ███╗   ███╗███████╗                                                            ||
||        ██╔══██╗██╔════╝██╔══██╗██╔══██╗████╗ ████║██╔════╝                                                            ||
||        ██████╔╝█████╗  ███████║██║  ██║██╔████╔██║█████╗                                                              ||
||        ██╔══██╗██╔══╝  ██╔══██║██║  ██║██║╚██╔╝██║██╔══╝                                                              ||
||        ██║  ██║███████╗██║  ██║██████╔╝██║ ╚═╝ ██║███████╗                                                            ||
||        ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚═════╝ ╚═╝     ╚═╝╚══════╝                                                            ||
||                                                                                                                       ||
||                                                                                                                       ||
||    This file is autogenerated, DO NOT send pull requests that changes this file directly.                             ||
||    You should update the script that does the generation, which can be found in:                                      ||
||    https://github.com/elastic/elastic-client-generator-js                                                             ||
||                                                                                                                       ||
||    You can run the script with the following command:                                                                 ||
||       npm run elasticsearch -- --version <version>                                                                    ||
||                                                                                                                       ||
||                                                                                                                       ||
||                                                                                                                       ||
===========================================================================================================================
////////

[discrete]
=== client.security.authenticate

Authenticate a user. Authenticates a user and returns information about the authenticated user. Include the user information in a [basic auth header](https://en.wikipedia.org/wiki/Basic_access_authentication). 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. If the user cannot be authenticated, this API returns a 401 status code.

{ref}/security-api-authenticate.html[{es} documentation]

[discrete]
==== Function signature

[source,ts]
----
(SecurityAuthenticateRequest, options?): Promise<SecurityAuthenticateResponse>
----

[discrete]
===== `SecurityAuthenticateRequest`

[source,ts]
----
interface SecurityAuthenticateRequest extends <<shared-type-request-base, RequestBase>> {
}
----

[discrete]
===== `SecurityAuthenticateResponse`

[source,ts]
----
interface SecurityAuthenticateResponse {
  api_key?: SecurityApiKey
  authentication_realm: SecurityRealmInfo
  email?: string | null
  full_name?: <<shared-type-name, Name>> | null
  lookup_realm: SecurityRealmInfo
  metadata: <<shared-type-metadata, Metadata>>
  roles: string[]
  username: <<shared-type-username, Username>>
  enabled: boolean
  authentication_type: string
  token?: SecurityAuthenticateToken
}
----

