I found a workaround that worked for me on Android.
Not sure why, but direct authenticated request:
req.open(method, fullurl, true, user, pass); req.send(data);
didn't work for me - it always returned 401. So instead, I tried to set basic authentication through the header:
req.open(method, fullurl, true); req.setRequestHeader("Authorization", "Basic " + Base64.encode(user + ":" + pass)); req.send(data);
(where Base64 is taken from here: fooobar.com/questions/5484 / ... ) - and it worked! Perhaps this is a bug in the implementation of XmlHttpRequest on Android.
source share