When visiting the url, I get a basic-auth prompt, fill in the exact same username and password as typed in the code. And I successfully login. When trying the same with unity I get the following error:
You are trying to load data from a www stream which had the following error when downloading.
403 FORBIDDEN
I know I’m on the right track because before I would get 401 authorization required.
The server is an ubuntu 12.04 with apache2.
void LoginUser(string enteredUsername, string enteredPassword){
encryptedPassword = md5(enteredPassword);
WWWForm form = new WWWForm();
form.AddField("our_username", enteredUsername);
form.AddField("our_password", encryptedPassword);
rawData = form.data;
Hashtable header = new Hashtable();
header = form.headers;
header.Add("Authorization", "Basic " + System.Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes("username:password")));
www = new WWW(url, rawData, header);
StartCoroutine(WaitForRequest(www));
// Application.LoadLevel("Game");
}
IEnumerator WaitForRequest(WWW www){
yield return www;
Debug.Log(www.text);
// check for errors
if (www.error == null){
Debug.Log("WWW Ok!: " + www.text);
} else {
Debug.Log("WWW Error: "+ www.error);
}
}