Skip to content

Instantly share code, notes, and snippets.

View AhmadiRamin's full-sized avatar

Ramin Ahmadi AhmadiRamin

View GitHub Profile
@AhmadiRamin
AhmadiRamin / SharePointAppOnlyHelper.ts
Last active October 3, 2020 13:24
SharePoint App Only Helper
/*
If you have a .Net Core/Standard solution or you don't want to use PnP Authentication Manager, this is the best approach to get SharePoint App Only Permission.
1- Create an App Registration in Azure
2- Navigate to http://<SharePointWebSite>/_layouts/15/AppInv.aspx and follow the steps from the link below to give your application access:
https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/add-in-permissions-in-sharepoint
3- Add this class to your solution and install Microsoft.SharePointOnline.CSOM NuGet Package.
4- Update Client Id, Client Secret and Tenant Id in this class
5- Get the SharePoint context and do what your application needs to do: