SharePoint Online authentication using CSOM
Jerryzy 10,436
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
Comments
Post a Comment