0
votes

When I am using HttpWebRequest I use the following code to set the Credentials

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlToCall);
request.Method = "GET";
request.Credentials = new NetworkCredential(username, pass);

How do I do the same when I am using BackgroundTransferService in Windows Phone 8.

For reference I am using the following.
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202955%28v=vs.105%29.aspx
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202959%28v=vs.105%29.aspx

*Edit: The authentication method is Digest This is what I get in the Authorization Header when I use my browser to download the file.

Digest username="adf", realm="bcd", nonce="XXXXXXXXX", uri="/ans/1268e52399.txt", algorithm=MD5, response="XXXXXXXXXXXXXXX", qop=auth, nc=00000001, cnonce="XXXXXXXXXXXX"

1

1 Answers

0
votes

Unfortunately this isn't supported on the BackgroundTranserService. One possible solution might be to manually create a header for your request like below:

var credentials = new UTF8Encoding().GetBytes(username + ":" +password);

var transferRequest = new BackgroundTransferRequest(transferUri);

transferRequest.Headers["Authorization"] ="Basic " + convert.ToBase64String(credentials);

Unfortunately I'm unable to test this at the minute, give it a try and let me know how you get on.