Search Posts

Category: basic-authentication

How to pass basic authentication in rest service in AngularJS?

I have a REST web service that requires a basic authentication to consume its data. I am consuming it in AngularJS. The way I am doing it is as follows: $http.get(‘http://localhost:9200/persons/_search?_source=Gender’, { headers: { withCredentials: true, headers:{ ‘Authorization’: ‘Basic ‘ + btoa(“admin” + “:” + “admin”)} } }). then(function(response) { ctrl.json = response.data; }); }]); But the error that I am having in the console is: Request header field headers is not allowed by Access-Control-Allow-Headers […]