CSOM SharePoint Online AuthenticationManager Client Credentaial flow support

Copper Contributor



I am in the process to write a console app to access SharePoint Online without interactive user log in.


I am thinking using clientID and clientSecret in code so no user login is required.


Does anyone know if it is supported. If it is, any links will be appreciated







4 Replies

Thanks for the reply and link. I am thinking using Azure AD to register the app so the app security will be managed by Azure AD in consistent with other Azure services.

Might I ask what do you want to achieve? Registering as an Azure AD App might require you have to use the Microsoft Graph to work with SPO. By the way, it's also possible to follow a similar approach to the one described in the link

Hi Joe,

PnP Team has created PnP Core APIs as wrapper on top of Microsoft CSOM APIs which provides lot of extension methods.  Do below steps to PnP Core nuget package to your console app.


1. In your console application project, right click in VS solution and select Manage Nuget packages for solution.

2. Search for 'SharePointPnPCoreOnline' package and install it. It install all dependent packages as well.

3. Once installed, you can use below namespace in using section


using Microsoft.SharePoint.Client;
using OfficeDevPnP.Core;


4. Then you can use AuthenticatonManager class to create SharePoint context as below.


var authManager = new OfficeDevPnP.Core.AuthenticationManager();
string appId = "<SharePoint App Client ID>";
string appSecret = "<SharePoint App Client Secret>";
string siteURL = "<SiteURL>";

using(ClientContext context = authManager.GetAppOnlyAuthenticatedContext(siteURL, appId, appSecret))
Site objSite = context.Site;
Console.WriteLine("Site Url:" + objSite.Url);