With jQuery I am calling [Version One Rest API][1] 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.
1. How to authenticate user with jQuery in HTTP headers?
2. 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).
[1]: http://community.versionone.com/sdk/Documentation/CoreAPI.aspx "I want to access server via only one account but do not want users on client side to see the password" - that is going to be impossible with this method unless you fetch the password from server side (which feels like a bad practice). Base64 encoding is NOT a way to make a password invisible, it is childishly easy to revert.