Im trying to make an extension to Safari that authenticates with http://myphotodiary.com's API. And it works well, for all passwords that dont include special characters like:
å,ä,ö and space
I have the following code working now:
var xmlHttp = new XMLHttpRequest();
var url = "https://api.myphotodiary.com/user_status.json?api_key=66217f993f25a8a05dd72970473aa2227450dcad";
var username = "iphone";
var password = "bdbiphone123";
var authy = Base64.encode(username+":"+password);
xmlHttp.open('GET', url, true);
xmlHttp.setRequestHeader("Authorization", "Basic " + authy);
xmlHttp.onreadystatechange = function(){
if (xmlHttp.readyState == 4){
var data;
eval("data="+xmlHttp.responseText);
console.log(data);
}
};
xmlHttp.send(null);
This code works great for all passwords that dont include the special characters, but if i change the login info to
var username = "blpninja";
var password = "./ hejä";
it starts to fail.
This exact code works in Safari, but not when i put it in an extension.
I have also tried the xmlHttpRequest.open built in authentication
xmlHttp.open('GET', url, true, username, password);
with the same result.
This is my head of the global page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
I get the "Failed to load resource: cancelled" and these are the headers Safari is sending:
Authorization:Basic YmxwbmluamE6Li8gaGVqw6Q=
Content-Type:text/xml; charset=utf-8
User-Agent:Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; sv-se) AppleWebKit/533.16 (KHTML, like Gecko)