public GetAzureADWebApplicationAuthenticatedContext ( String siteUrl, String>.Func |
||
siteUrl | String | Site for which the ClientContext object will be instantiated |
accessTokenGetter | String>.Func | The AccessToken getter method to use |
return | ClientContext |
public static void BrowseFilesLibrary() { // Create a PnP AuthenticationManager object AuthenticationManager am = new AuthenticationManager(); // Authenticate against SPO with a delegated access token using (ClientContext context = am.GetAzureADWebApplicationAuthenticatedContext( O365ProjectsAppContext.CurrentSiteUrl, (url) => { return (MicrosoftGraphHelper.GetAccessTokenForCurrentUser(url)); })) { Web web = context.Web; var targetLibrary = web.GetListByTitle(O365ProjectsAppSettings.LibraryTitle); context.Load(targetLibrary.RootFolder, fld => fld.ServerRelativeUrl, fld => fld.Files.Include(f => f.Title, f => f.ServerRelativeUrl)); context.ExecuteQueryRetry(); foreach (var file in targetLibrary.RootFolder.Files) { // Handle each file object ... this is just a sample ... } } }