[[reference-security-get_token]]

////////
===========================================================================================================================
||                                                                                                                       ||
||                                                                                                                       ||
||                                                                                                                       ||
||        ██████╗ ███████╗ █████╗ ██████╗ ███╗   ███╗███████╗                                                            ||
||        ██╔══██╗██╔════╝██╔══██╗██╔══██╗████╗ ████║██╔════╝                                                            ||
||        ██████╔╝█████╗  ███████║██║  ██║██╔████╔██║█████╗                                                              ||
||        ██╔══██╗██╔══╝  ██╔══██║██║  ██║██║╚██╔╝██║██╔══╝                                                              ||
||        ██║  ██║███████╗██║  ██║██████╔╝██║ ╚═╝ ██║███████╗                                                            ||
||        ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚═════╝ ╚═╝     ╚═╝╚══════╝                                                            ||
||                                                                                                                       ||
||                                                                                                                       ||
||    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.getToken

Get a token. Create a bearer token for access without requiring basic authentication.

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

[discrete]
==== Function signature

[source,ts]
----
(SecurityGetTokenRequest, options?): Promise<SecurityGetTokenResponse>
----

[discrete]
===== `SecurityGetTokenRequest`

[source,ts]
----
interface SecurityGetTokenRequest extends <<shared-type-request-base, RequestBase>> {
  grant_type?: SecurityGetTokenAccessTokenGrantType
  scope?: string
  password?: <<shared-type-password, Password>>
  kerberos_ticket?: string
  refresh_token?: string
  username?: <<shared-type-username, Username>>
}
----

[discrete]
===== `SecurityGetTokenResponse`

[source,ts]
----
interface SecurityGetTokenResponse {
  access_token: string
  expires_in: <<shared-type-long, long>>
  scope?: string
  type: string
  refresh_token?: string
  kerberos_authentication_response_token?: string
  authentication: SecurityGetTokenAuthenticatedUser
}
----

