async def get_token(
        self,
        *,
        error_trace: t.Optional[bool] = None,
        filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
        grant_type: t.Optional[
            t.Union[
                str,
                t.Literal[
                    "_kerberos", "client_credentials", "password", "refresh_token"
                ],
            ]
        ] = None,
        human: t.Optional[bool] = None,
        kerberos_ticket: t.Optional[str] = None,
        password: t.Optional[str] = None,
        pretty: t.Optional[bool] = None,
        refresh_token: t.Optional[str] = None,
        scope: t.Optional[str] = None,
        username: t.Optional[str] = None,
        body: t.Optional[t.Dict[str, t.Any]] = None,
    ) -> ObjectApiResponse[t.Any]:
        """
        .. raw:: html

          <p>Get a token.</p>
          <p>Create a bearer token for access without requiring basic authentication.
          The tokens are created by the Elasticsearch Token Service, which is automatically enabled when you configure TLS on the HTTP interface.
          Alternatively, you can explicitly enable the <code>xpack.security.authc.token.enabled</code> setting.
          When you are running in production mode, a bootstrap check prevents you from enabling the token service unless you also enable TLS on the HTTP interface.</p>
          <p>The get token API takes the same parameters as a typical OAuth 2.0 token API except for the use of a JSON request body.</p>
          <p>A successful get token API call returns a JSON structure that contains the access token, the amount of time (seconds) that the token expires in, the type, and the scope if available.</p>
          <p>The tokens returned by the get token API have a finite period of time for which they are valid and after that time period, they can no longer be used.
          That time period is defined by the <code>xpack.security.authc.token.timeout</code> setting.
          If you want to invalidate a token immediately, you can do so by using the invalidate token API.</p>


        `<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-token>`_

        :param grant_type: The type of grant. Supported grant types are: `password`,
            `_kerberos`, `client_credentials`, and `refresh_token`.
        :param kerberos_ticket: The base64 encoded kerberos ticket. If you specify the
            `_kerberos` grant type, this parameter is required. This parameter is not
            valid with any other supported grant type.
        :param password: The user's password. If you specify the `password` grant type,
            this parameter is required. This parameter is not valid with any other supported
            grant type.
        :param refresh_token: The string that was returned when you created the token,
            which enables you to extend its life. If you specify the `refresh_token`
            grant type, this parameter is required. This parameter is not valid with
            any other supported grant type.
        :param scope: The scope of the token. Currently tokens are only issued for a
            scope of FULL regardless of the value sent with the request.
        :param username: The username that identifies the user. If you specify the `password`
            grant type, this parameter is required. This parameter is not valid with
            any other supported grant type.
        """
        __path_parts: t.Dict[str, str] = {}
        __path = "/_security/oauth2/token"
        __query: t.Dict[str, t.Any] = {}
        __body: t.Dict[str, t.Any] = body if body is not None else {}
        if error_trace is not None:
            __query["error_trace"] = error_trace
        if filter_path is not None:
            __query["filter_path"] = filter_path
        if human is not None:
            __query["human"] = human
        if pretty is not None:
            __query["pretty"] = pretty
        if not __body:
            if grant_type is not None:
                __body["grant_type"] = grant_type
            if kerberos_ticket is not None:
                __body["kerberos_ticket"] = kerberos_ticket
            if password is not None:
                __body["password"] = password
            if refresh_token is not None:
                __body["refresh_token"] = refresh_token
            if scope is not None:
                __body["scope"] = scope
            if username is not None:
                __body["username"] = username
        __headers = {"accept": "application/json", "content-type": "application/json"}
        return await self.perform_request(  # type: ignore[return-value]
            "POST",
            __path,
            params=__query,
            headers=__headers,
            body=__body,
            endpoint_id="security.get_token",
            path_parts=__path_parts,
        )

        .. raw:: html

          <p>Get a token.</p>
          <p>Create a bearer token for access without requiring basic authentication.
          The tokens are created by the Elasticsearch Token Service, which is automatically enabled when you configure TLS on the HTTP interface.
          Alternatively, you can explicitly enable the <code>xpack.security.authc.token.enabled</code> setting.
          When you are running in production mode, a bootstrap check prevents you from enabling the token service unless you also enable TLS on the HTTP interface.</p>
          <p>The get token API takes the same parameters as a typical OAuth 2.0 token API except for the use of a JSON request body.</p>
          <p>A successful get token API call returns a JSON structure that contains the access token, the amount of time (seconds) that the token expires in, the type, and the scope if available.</p>
          <p>The tokens returned by the get token API have a finite period of time for which they are valid and after that time period, they can no longer be used.
          That time period is defined by the <code>xpack.security.authc.token.timeout</code> setting.
          If you want to invalidate a token immediately, you can do so by using the invalidate token API.</p>


        `<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-token>`_

        :param grant_type: The type of grant. Supported grant types are: `password`,
            `_kerberos`, `client_credentials`, and `refresh_token`.
        :param kerberos_ticket: The base64 encoded kerberos ticket. If you specify the
            `_kerberos` grant type, this parameter is required. This parameter is not
            valid with any other supported grant type.
        :param password: The user's password. If you specify the `password` grant type,
            this parameter is required. This parameter is not valid with any other supported
            grant type.
        :param refresh_token: The string that was returned when you created the token,
            which enables you to extend its life. If you specify the `refresh_token`
            grant type, this parameter is required. This parameter is not valid with
            any other supported grant type.
        :param scope: The scope of the token. Currently tokens are only issued for a
            scope of FULL regardless of the value sent with the request.
        :param username: The username that identifies the user. If you specify the `password`
            grant type, this parameter is required. This parameter is not valid with
            any other supported grant type.
        
elasticsearch/_async/client/security.py