preset-io / elasticsearch-dbapi

A DBAPI and SQLAlchemy dialect for Elasticsearch
Apache License 2.0
108 stars 50 forks source link

Unclear how to get past Basic Authentication #87

Open provtemp opened 2 years ago

provtemp commented 2 years ago

It is not clear to me how to query an endpoint that uses HTTP Basic Authentication. I tried

    engine = create_engine(
        "elasticsearch+https://.../",
        connect_args={"password": credentials.password, "user": credentials.login},
    )

but that neither puts an Authorization header in the request, nor does it automatically retry with one upon receiving the HTTP/1.1 401 Unauthorized response, using

elastic-transport==8.0.1
elasticsearch==8.0.1
elasticsearch-dbapi==0.2.2
SQLAlchemy==1.4.32

There should at least be an example in the documentation.

provtemp commented 2 years ago

https://github.com/preset-io/elasticsearch-dbapi/blob/0d5a93058fc82071169f199bfae85d7b5162a12a/es/baseapi.py#L318

Removing ^ .transport seems to work.