Skip to content

Allow passing a custom authentication class to httpx client #2933

Open
@vruello

Description

@vruello

When instantiating Elasticsearch or AsyncElasticsearch, it is possible to pass a parameter named http_auth.

If node_class is requests and http_auth is a subclass of requests.auth.AuthBase, http_auth is passed to client_node_configs which stores it in the node config (extra["requests.session.auth"]) (https://github.com/elastic/elasticsearch-py/blob/main/elasticsearch/_sync/client/utils.py#L130).

The requests node retrieves this parameter from config and passes it to the requests session
(https://github.com/elastic/elastic-transport-python/blob/main/elastic_transport/_node/_http_requests.py#L147).

This behavior was introduced by #1944 (elasticsearch-py) and elastic/elastic-transport-python#48 (elastic-transport-python).

requests is not the only http client to support a custom authentication class. It can also be done by httpx (auth parameter of Client or AsyncClient (https://www.python-httpx.org/api/#asyncclient)).

Would you accept a PR that adds the support for http_auth when using the httpx node class?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions