Elasticsearch 8.1 - python security client issues

Hi Elastic Community,

We are having problems trying to connect a python (2.7.5) client to Elasticsearch 8.1 (with security enabled).

We have tried the following example code:

from elasticsearch import Elasticsearch
from es_pandas import es_pandas

# Password for the 'elastic' user generated by Elasticsearch
ELASTIC_PASSWORD = "s4cCzeuWasAu7l_n9tph"

# Create the client instance
#The ca_certs file is from elasticsearch server (<elastic>/config/certs/http_ca.crt).
client = Elasticsearch(
    "https://10.162.18.239:9200",
    ca_certs="/opt/pythonclient/certs/http_ca.crt",
    basic_auth=("elastic", ELASTIC_PASSWORD)
)

client.info()

The error is:

elasticsearch.exceptions.AuthenticationException: AuthenticationException(401, 'security_exception', 'missing authentication credentials for REST request [/]')

Any suggestions on how to set the credentials?

Regards

Aldo Fiorentini

Hi @Aldo2

We only support Python 3.6 and above for the latest clients. So can I recommend that you try your code with a newer version of the language instead.

Thanks
Nigel

Hi to all,

Works fine using "http_auth" instead of "basic_auth".

Regards

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.