title: Download a File from SharePoint Online C#
body: <p>Refering to: <strong><a href="https://stackoverflow.com/questions/23684101/download-file-from-sharepoint-365">Download File From SharePoint 365</a></strong></p>
  <p>I am using the exact same code and am getting the 401 &quot;unauthorized&quot; exception.</p>
  <p>I also added the <em>useDefaultCredentials=True</em>, but no difference.</p>
  <p>And the SharePoint.Online.CSOM is not working in .Net Core so i´m using TTCUE.</p>
  <pre><code>using (var client = new WebClient())
  {
       SharePointOnlineCredentials Creds = new SharePointOnlineCredentials(username, password);       
       client.UseDefaultCredentials = true;
       client.Headers.Add(&quot;X-FORMS_BASED_AUTH_ACCEPTED&quot;, &quot;f&quot;);
       client.Headers.Add(&quot;User-Agent: Other&quot;);
       client.Credentials = Creds;
       Console.WriteLine(rootSite + sourceSite + folderSite + fileSite);
       client.DownloadFile(rootSite+sourceSite+folderSite+fileSite, destinationPath);
  }
  </code></pre>