PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, October 24, 2022

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

 October 24, 2022     authentication, elastic-stack, elasticsearch, kibana, rest     No comments   

Issue

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
}


Solution

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

enter image description here

enter image description here



Answered By - Eduardo de Santana
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing