Martin Stoll

Martin Stoll

  • 1.9k
  • 2
  • 209

C# CSOM - Get authorized view url of a file

Feb 20 2020 11:19 AM


is there a way to get a authorized url of specific file stored in SharePoint Online?

I have an (win) application, that can upload files fine. Later, the file (the uniequid is stored in a database) should be show in a webbrowser control without login.

Similar to Listitem.File.GetPreAuthorizedAccessUrl(), this works?

For Example ServerRelativeUrl + accesstoken.

Login with username and password works fine. (below the Sourcecode)
  1. "********".ToList().ForEach(c => securePassword.AppendChar(c));  
  2.                     clientContext = new ClientContext("");//Credentials.URL);  
  3.                     clientContext.Credentials = new SharePointOnlineCredentials("", securePassword);  

Any ideas?

Brought to you by: JavaScript SDK for Bold BI dashboard and analytics embedding. Free trial.