From 514ade5c9aebddbc2cf3d59c53c7d2d2023d8a5e Mon Sep 17 00:00:00 2001 From: nathan-swannet <42999227+nathan-swannet@users.noreply.github.com> Date: Fri, 14 Jun 2024 09:43:12 +0200 Subject: [PATCH 1/2] Update AuthenticationManager.cs --- src/lib/PnP.Framework/AuthenticationManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/PnP.Framework/AuthenticationManager.cs b/src/lib/PnP.Framework/AuthenticationManager.cs index 701f739bc..24412a03f 100644 --- a/src/lib/PnP.Framework/AuthenticationManager.cs +++ b/src/lib/PnP.Framework/AuthenticationManager.cs @@ -1352,7 +1352,7 @@ public ClientContext GetOnPremisesContext(string siteUrl) internal void ConfigureOnPremisesContext(string siteUrl, ClientContext clientContext) { - clientContext.ExecutingWebRequest += (sender, webRequestEventArgs) => + clientContext.ExecutingWebRequest += async (sender, webRequestEventArgs) => { // CSOM for .NET Standard 2.0 is not sending along credentials for an on-premises request, so ensure // credentials and request digest are in place. This will make CSOM for .NET Standard work for @@ -1364,7 +1364,7 @@ internal void ConfigureOnPremisesContext(string siteUrl, ClientContext clientCon // PowerShell do support SharePoint on-premises. webRequestEventArgs.WebRequestExecutor.WebRequest.Credentials = (sender as ClientContext).Credentials; // CSOM for .NET Standard does not handle request digest management, a POST to client.svc requires a digest, so ensuring that - webRequestEventArgs.WebRequestExecutor.RequestHeaders["X-RequestDigest"] = (sender as ClientContext).GetOnPremisesRequestDigestAsync().GetAwaiter().GetResult(); + webRequestEventArgs.WebRequestExecutor.RequestHeaders["X-RequestDigest"] = await (sender as ClientContext).GetOnPremisesRequestDigestAsync(); // Add Request Header to force Windows Authentication which avoids an issue if multiple authentication providers are enabled on a webapplication webRequestEventArgs.WebRequestExecutor.RequestHeaders["X-FORMS_BASED_AUTH_ACCEPTED"] = "f"; }; From c47fabb62ce5bfd444e6db501e8f9529abf37c3d Mon Sep 17 00:00:00 2001 From: nathan-swannet <42999227+nathan-swannet@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:35:05 +0200 Subject: [PATCH 2/2] Update AuthenticationManager.cs --- src/lib/PnP.Framework/AuthenticationManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/PnP.Framework/AuthenticationManager.cs b/src/lib/PnP.Framework/AuthenticationManager.cs index 24412a03f..e8b2fe0cf 100644 --- a/src/lib/PnP.Framework/AuthenticationManager.cs +++ b/src/lib/PnP.Framework/AuthenticationManager.cs @@ -1352,7 +1352,7 @@ public ClientContext GetOnPremisesContext(string siteUrl) internal void ConfigureOnPremisesContext(string siteUrl, ClientContext clientContext) { - clientContext.ExecutingWebRequest += async (sender, webRequestEventArgs) => + clientContext.ExecutingWebRequest += (sender, webRequestEventArgs) => { // CSOM for .NET Standard 2.0 is not sending along credentials for an on-premises request, so ensure // credentials and request digest are in place. This will make CSOM for .NET Standard work for @@ -1364,7 +1364,7 @@ internal void ConfigureOnPremisesContext(string siteUrl, ClientContext clientCon // PowerShell do support SharePoint on-premises. webRequestEventArgs.WebRequestExecutor.WebRequest.Credentials = (sender as ClientContext).Credentials; // CSOM for .NET Standard does not handle request digest management, a POST to client.svc requires a digest, so ensuring that - webRequestEventArgs.WebRequestExecutor.RequestHeaders["X-RequestDigest"] = await (sender as ClientContext).GetOnPremisesRequestDigestAsync(); + webRequestEventArgs.WebRequestExecutor.RequestHeaders["X-RequestDigest"] = Task.Run(async () => await (sender as ClientContext).GetOnPremisesRequestDigestAsync()).GetAwaiter().GetResult(); // Add Request Header to force Windows Authentication which avoids an issue if multiple authentication providers are enabled on a webapplication webRequestEventArgs.WebRequestExecutor.RequestHeaders["X-FORMS_BASED_AUTH_ACCEPTED"] = "f"; };