Sharepoint - Access Documents - SSO

Occasional Visitor

Hi,

 

I am using the Sharepoint CSOM API to access Sharepoint Online and access/download/upload files.

SharePointOnlineCredentials is used to set up the credentials (username, password). Is there a way to use the currently signed in windows user (instead of providing the username and password)?

 

The following piece of code is used to get a list of files.

 

ClientContext ctx = new ClientContext(siteUrl);
// Use UserName/Password to access the sharepoint
ctx.Credentials = new SharePointOnlineCredentials("phil.collins@singer.com", theSecureString);

FileCollection files = ctx.Web.GetFolderByServerRelativeUrl(folderPath).Files;
ctx.Load(files);
ctx.ExecuteQuery();

0 Replies