4
votes

I trying list data from Elastic Search using the REST API from POSTMAN. But I has ´security_exception´

I read the elastic documentation from https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html but isn'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 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
}

1
can you explain step by step what u are doing? is _securty is your index?user156327
I need list data from any index example: "GET xxx.xxx.xxx.xxx:9200/name_index/name_type/_search" using postmant or any external client. But my elastic use authentication by "user/password" How I can list my index data using that REST SERVICE? I think need get the authentication token before then put the token into the rest request. This is the documentation of use the SECURITY API elastic.co/guide/en/elasticsearch/reference/current/… Can you help me?Marcos Peralta

1 Answers

13
votes

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

enter image description here

enter image description here