I am trying to download item that exists in Office 365 SharePoint library using WebcClient.DownloadFile() but i am getting this exception:
Exception :
The remote server returned an error: (403) Forbidden.
Sample code :
NetworkCredential credential = new NetworkCredential("username", "password", "aaa.onmicrosoft.com");
WebClient webClient = new WebClient();
webClient.Credentials = credential;
webClient.DownloadFile(@"https://aaa.sharepoint.com/testDoc/test.pdf", @"c:/test.pdf");
With a bit of help from my friends, I’ve managed to crack this SharePoint on-line authentication stuff 🙂
I was kindly pointed in the direction of this blog post from Wictor Wilén.
And my WebClient call that uses Wictors claims library code…