# Missing authentication credentials for REST request

**URL:** <https://discuss.elastic.co/t/missing-authentication-credentials-for-rest-request/271215>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-security\
**Created:** [April 26, 2021, 5:28am UTC](https://discuss.elastic.co/t/missing-authentication-credentials-for-rest-request/271215 "2021-04-26T05:28:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jojbapsaekki](https://avatars.discourse-cdn.com/v4/letter/j/8797f3/32.png) [@jojbapsaekki](https://discuss.elastic.co/u/jojbapsaekki)\
**Post date:** [April 26, 2021, 5:28am UTC](https://discuss.elastic.co/t/missing-authentication-credentials-for-rest-request/271215/1 "2021-04-26T05:28:38Z")

</div>

```auto
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12

```

```auto
Changed password for user apm_system
PASSWORD apm_system = KXCtBDwpm9ARMEpHBBr7

Changed password for user kibana_system
PASSWORD kibana_system = RF3Z7WfP05Iz4UqaQwv6

Changed password for user kibana
PASSWORD kibana = RF3Z7WfP05Iz4UqaQwv6

Changed password for user logstash_system
PASSWORD logstash_system = RMUY26uScdJoc1FwerXc

Changed password for user beats_system
PASSWORD beats_system = QTpFzdVUT8e7cna7y3z7

Changed password for user remote_monitoring_user
PASSWORD remote_monitoring_user = 89npTHP9Qt3NAUCuUNq9

Changed password for user elastic
PASSWORD elastic = x45gqZbnXlxSzxoOrXfd

```

```auto
 $.ajax({
        timeout : 10000
        ,cache : true
        ,async : false
        ,dataType : "json"
        ,type : "POST"
        ,contentType: 'application/json'
        ,url : 'http://localhost:9200/_search'
        ,data : params
        ,success : function(data, status, xhr){
            if(callbackFn) {
                callbackFn(data, callbackParam || '');
            }
        }
        ,error	: function(xhr,status,error){
            console.log(url, xhr);
            console.log(error);
        }
    });

```

then.....

{"error":{"root\_cause":[{"type":"security\_exception","reason":"missing authentication credentials for REST request [/test\_index/\_search]

I want to know how to call Ajax after applying security to ElasticSearch. What am I supposed to do??

```auto
$.ajax({
        timeout : 10000
        ,cache : true
        ,async : false
        ,dataType : "json"
        ,type : "POST"
        ,headers: {
            'Authorization': 'Basic ' + btoa('elastic :x45gqZbnXlxSzxoOrXfd')
        }
        ,contentType: 'application/json'
        ,url : 'http://localhost:9200/_search/'
        ,data : params
        ,success : function(data, status, xhr){
            if(callbackFn) {
                callbackFn(data, callbackParam || '');
            }
        }
        ,error	: function(xhr,status,error){
            console.log(url, xhr);
            console.log(error);
        }
    });

```

```auto
DOMException: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://localhost:9200/test_index/_search?pretty'.
    at Object.send (https://code.jquery.com/jquery-3.4.1.js:9837:10)
    at Function.ajax (https://code.jquery.com/jquery-3.4.1.js:9434:15)
    at jsonAjax (http://localhost:8080/resources/common/js/common.js:160:7)
    at getListPage (http://localhost:8080/resources/common/js/common.js:111:9)
    at Object.init (http://localhost:8080/resources/common/js/common.js:133:17)
    at http://localhost:8080/tables:169:30

```

not working..... please help...

---

<div class="post-metadata">

**Author:** ![jojbapsaekki](https://avatars.discourse-cdn.com/v4/letter/j/8797f3/32.png) [@jojbapsaekki](https://discuss.elastic.co/u/jojbapsaekki)\
**Post date:** [April 26, 2021, 5:51am UTC](https://discuss.elastic.co/t/missing-authentication-credentials-for-rest-request/271215/2 "2021-04-26T05:51:17Z")

</div>

I have solved.

elasticsearch.yml

add

http.cors.allow-headers: "Authorization, X-Requested-With, Content-Type, Content-Length"

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 24, 2021, 5:52am UTC](https://discuss.elastic.co/t/missing-authentication-credentials-for-rest-request/271215/3 "2021-05-24T05:52:10Z")

</div>

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