SharePoint Online authentication using CSOM

Jerryzy 
10,436Reputation points
Apr 1, 2021, 9:55 PM

Hi @Lakshman Bana ,

PnP.Framework Library supported to use App Id and App Secret to get the ClientContext and this library supported both .NET Framework and .NET Standard:

Please first install PnP.Core as this is the dependent package for PnP.Framework:

Install-Package PnP.Core -Version 1.1.0  
Install-Package PnP.Framework -Version 1.4.0  

Then authentication with App Id and AppSecret ( register in https://siteurl/_layouts/15/AppRegNew.aspx) like this:

using Microsoft.SharePoint.Client;  
using PnP.Framework;  
  
ClientContext ctx = new AuthenticationManager().GetACSAppOnlyContext("SiteUrl", "AppId", "AppSecret");  
ctx.Load(ctx.Web);  
ctx.ExecuteQuery();  

Here is a detailed blog for your reference:

https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs

Recommend: M365 – SharePoint Online – CSOM – Getting SharePoint client context using PnP.Framework in .NET Core application

https://learn.microsoft.com/en-us/answers/questions/341294/how-to-perform-sharepoint-online-authentication-in?orderby=newest&source=docs



Comments

Popular posts from this blog

Use GnuPG Tools or C# Code for PGP Encryption and Signature

Errors in Net Core Add-Migration

Confusing Concepts about SFTP: SSH2 vs OpenSSH