Using Ajax in Angular I want to get some data from a URL that needs authentication. The curl command for getting this data outside of ajax is:
curl -u some_username:password 'https://website.com'
This is my function:
function getCurlData() {
window.btoa("some_username:password");
return $http.get("https://website.com").success( function(data) {
console.log(data);
}).catch(function() {
console.log("failed");
});
However I get a 403 forbidden message upon using this function. How can I retrieve the data?
Authorization
header is described in Wikipedia Basic Access Authorization. Be aware that the server needs to set the CORS Access-Control-Allow-Credentials Header.