Connect to Elastic Cloud using python client

I am using python client to connect to Elastic Cloud. I have tried connecting using basic_auth and api_keys. In both instances it gives me the following error

elasticsearch.AuthorizationException: AuthorizationException(403, "{'ok': False, 'message': 'Forbidden'}")

Here is the sample code:

<< from elasticsearch import Elasticsearch

es = Elasticsearch(cloud_id=<<>>, api_key=(api_key_id, api_key))

es = Elasticsearch(cloud_id=<<>>, basic_auth=(username, password)) >>

Can someone help me with this?

Hi @Venkatesh_Guruprasad

Perhaps take a look at this thread

Perhaps you are using the wrong type of API Key as this user was

remember this is NOT and Elastic Cloud API key it is an Elasticsearch API key which can only be created via and API call see here

Actually API Keys can now be created via Kibana -> Stack Management -> API Keys as well now

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