Created
April 8, 2022 12:28
-
-
Save krusli/96fb927f1f592a4e33243750cf4885e1 to your computer and use it in GitHub Desktop.
PnP Framework Interactive Auth for SharePoint Online/365 - Simple Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using PnP.Framework; | |
/* Reference: | |
Auth | |
- https://www.inkeysolutions.com/blogs/secure-authentication-of-sharepoint-with-pnp-framework-with-ccode/ | |
- https://knowledge-junction.com/2021/01/25/m365-sharepoint-online-csom-getting-sharepoint-client-context-using-pnp-framework-in-net-core-application/ | |
Reading Changelog | |
- https://www.schaeflein.net/reading-the-sharepoint-change-log-from-csom/ | |
*/ | |
string siteUrl = ""; | |
string clientId = ""; | |
string clientSecret = ""; | |
string tenantId = ""; | |
var authManager = AuthenticationManager.CreateWithInteractiveLogin(clientId: clientId, tenantId: tenantId, redirectUrl: "http://localhost"); | |
using (var clientContext = authManager.GetContext(siteUrl)) | |
{ | |
clientContext.Load(clientContext.Web, p => p.Title); | |
clientContext.ExecuteQuery(); | |
Console.WriteLine(clientContext.Web.Title); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment