CSOM calls with Default Network Credentials


  • Hi Folks,

    I am trying to make CSOM calls from a Windows .NET(C#) application to a SharePoint Online Tenant. It works well with "SharePointOnlineCredentials".

    However, If I try to make the same CSOM call with Windows Integrated Authentication mode by using "DefaultNetworkCredentials", CSOM call does not work and it gives (401) Unauthorized error (Even though the logged in user is a Tenant Admin). 

    Is there a way to make CSOM calls to a SharePoint Online Tenant using Logged in User's credential?

    Further, following is the code snippet I use to make these CSOM calls.

    ClientContext ctx = new ClientContext(SiteURL);
    ctx.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
    ctx.AuthenticationMode = ClientAuthenticationMode.Default;
    ctx.ExecutingWebRequest += new EventHandler<WebRequestEventArgs>(ctx_MixedAuthRequest);
    Web web = ctx.Web;

    Thanks & Regards,


    Friday, June 10, 2016 12:50 AM

All replies