jQuery HTTP authentication

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.

以上就是jQuery HTTP authentication的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏