Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can get authentication token or do loging in Elastic Search using REST API? For example from POSTMAN

I'm trying to list data from Elastic Search using the REST API on Postman. But I get a security_exception error

I read the elastic documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html but didn't work.

I'm using Elastic 7.2

Method: POST

Content-type: Application/json

URI: http://xxx.xxx.xxx.xxx:9200/_security/oauth2/token

BODY: 

{
  "grant_type" : "password",
  "username" : "user_name",
  "password" : "correct_password"
}

I need this service to return the authentication token. But this is the response:

{
    "error": {
        "root_cause": [
            {
                "type": "security_exception",
                "reason": "missing authentication credentials for REST request [/_security/oauth2/token]",
                "header": {
                    "WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
                }
            }
        ],
        "type": "security_exception",
        "reason": "missing authentication credentials for REST request [/_security/oauth2/token]",
        "header": {
            "WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
        }
    },
    "status": 401
}

like image 759
Marcos Peralta Avatar asked Dec 11 '22 02:12

Marcos Peralta


1 Answers

Try to do a basic authentication instead. And pass in the body just the grant_type.

enter image description here

enter image description here

like image 143
Eduardo de Santana Avatar answered Mar 09 '23 00:03

Eduardo de Santana