No longer able to use OfficeDevPnP.Core.AuthenticationManager OR PnP.Framework.AuthenticationManager().GetACSAppOnlyContext

john john 946 Reputation points
2021-05-19T23:29:58+00:00

I usually run those command inside my CSOM code to authenticate to Office 365 using ClientId + ClientSecret:-

using (ClientContext context2 = new PnP.Framework.AuthenticationManager().GetACSAppOnlyContext(siteUrl, clientId, clientSecret, AzureEnvironment.Production))

&

using (ClientContext context3 = new OfficeDevPnP.Core.AuthenticationManager().GetAppOnlyAuthenticatedContext(siteUrl, clientId, clientSecret, AzureEnvironment.Production))

But starting from yesterday the above commands are raising these errors:-

Unhandled Exception: Microsoft.IdentityModel.SecurityTokenService.RequestFailedException: Token request failed. ---> System.Net.WebException: The remote server

any advice? i checked the expiry date for the app and it is still valid till july 2021..

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,300 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. MichaelHan-MSFT 18,026 Reputation points
    2021-05-20T02:32:14.51+00:00

    Hi @john john ,

    Could it be that the SharePoint app-only permissions is disabled for you tenant? You could check it with this command: get-spotenant | select DisableCustomAppAuthentication

    And you could run the below cmdlet to enable it: Set-SPOTenant -DisableCustomAppAuthentication $false


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. MichaelHan-MSFT 18,026 Reputation points
    2021-05-24T02:32:21.77+00:00
    0 comments No comments