public static ClientContext GetWebApplicationClientContext(TokenCache tokenCache) { string siteUrl = GetSharePointResourceID(tokenCache); OfficeDevPnP.Core.AuthenticationManager authManager = new OfficeDevPnP.Core.AuthenticationManager(); ClientContext context = authManager.GetAzureADWebApplicationAuthenticatedContext( siteUrl, (s) => GetTokenForApplication(s, tokenCache)); return(context); }