With jQuery I am calling Version One Rest API and need to authenticate user in HTTP header.
I tried
$.ajax({
dataType: "jsonp",
beforeSend: function(xhr){
xhr.setRequestHeader("Authorization", "Basic xyz"); // xyz usr:pwd Base64 encoded
},
url: "https://www10.v1host.com/.../VersionOne/rest-1.v1/...",
success: function(data, status, xhr) {
alert("Load was performed.");
}
});
and
$.ajax({
dataType: "jsonp",
username:"usr",
password:"pwd",
url: "https://www10.v1host.com/.../VersionOne/rest-1.v1/...",
success: function(data, status, xhr) {
alert("Load was performed.");
}
});
But I always get pop up asking for my credentials (I use Chrome). Even when I type credentials in the pop up, I am not authenticated and the window keeps showing.
- How to authenticate user with jQuery in HTTP headers?
- Is there any way how make password attribute encrypted invisible? Or Base64 is the only way. I want to access server via only one account but do not want users on client side to see the password (or find it in javascripts).