Hi @Vish Pothaganti ,
Instead of Azure AD application, please use the SharePoint application which register in this url:
https://siteurl/_layouts/15/appregnew.aspx
And then grant Full Control permission in SharePoint administration site:
https://tenantname-admin.sharepoint.com/_layouts/15/appinv.aspx
Click Trust:
Then in code snippet, use OfficeDevPnP.Core.AuthenticationManager().GetAppOnlyAuthenticatedContext(siteUrl,clientId,clientSecret) function:
string siteUrl = "your siteurl";
string clientId = "your client Id";
string clientSecret = "your client secret";
using (var ctx = new OfficeDevPnP.Core.AuthenticationManager().GetAppOnlyAuthenticatedContext(siteUrl,clientId,clientSecret))
{
};
Detailed steps to register app and grant permission, please refer this official document, Permission is necessary to set, otherwise, it will also return 401 unauthorized:
Granting access using SharePoint App-Only
Thanks
Best Regards
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.