Dan Sanders
  • Home
  • About
  • Contact
  • – PowerShell
  • – SharePoint
  • – Workflow
Copyright © 2016 Dan Sanders. All Rights Reserved.
Dan Sanders
  • Home
  • About
  • Contact
  • – PowerShell
  • – SharePoint
  • – Workflow

SharePoint Add-in 401 Unauthorized

byDan Sanders inUncategorized posted26 November, 2020
0
0

Recently on a new 365 tenant I discovered that after creating an Azure App Registration or new SharePoint App-Only / Add-in that I could not access SharePoint resources without being hit with 401 unauthorized errors.

The remote server returned and error: (401) Unauthorized.

I use Client IDs and Secrets to access SharePoint via PowerShell with CSOM and PnP so often grant an App ID full tenant access via the XML permissions detailed here.

I found that Connect-PnPOnline would successfully connect to the tenant but any attempt to Get-PnPWeb or Get-PnPSite would result in the 401 unauthorized access.
After much investigation I concluded that the XML add in permissions were being ignored in SharePoint and somehow Microsoft had made a change to break this and so I logged a MS Support ticket.

As usual, MS Support weren’t helpful, and after requesting updates for three weeks a colleague of mine found a new change that Microsoft had made that caused this issue and so I cancelled the ticket.

The change is this, Microsoft added a new tenant-level property called “DisableCustomAppAuthentication” to SharePoint Online and made the decision to set this property to be true by default affecting all new tenants post August 2020.

Solution
The solution is to set this new property to false as follows:
Set-SPOTenant -DisableCustomAppAuthentication $false
This requires the latest version of SharePoint online management shell.

References:
https://docs.microsoft.com/en-us/answers/questions/90187/sharepoint-app-only-add-ins-throwing-401-unauthori.html?WT.mc_id=M365-MVP-5003535

https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs

Office365PnPPowerShellSharePoint Online
Share this :

Related Posts

0
20 September, 2018
SharePoint helpful hidden URLs

Recently on a new 365 tenant I discovered that after creating an Azure App Registration or new...

8 Comments

Leave a Comment! Cancel reply

You must be logged in to post a comment.

Recent Posts

  • SharePoint Add-in 401 Unauthorized
  • Content Database and Site Collection Report
  • SharePoint helpful hidden URLs

Tags

Config (1) Content Types (2) Design (3) Document Libraries (7) Document Sets (1) How-To (1) Lists (4) Office365 (1) PnP (1) PowerShell (12) Quick Edit (2) REST (1) SharePoint (11) SharePoint 2010 (11) SharePoint 2013 (14) SharePoint Foundation (2) SharePoint Online (1) SP2010 Workflow (2) SP2013 Workflow (3) Systems (2) User Profile Service (1) Views (5) Windows Server (1) Workflow (2)

Archives

  • November 2020
  • December 2018
  • September 2018
  • July 2018
  • September 2017
  • August 2016
  • April 2016
  • March 2016
  • February 2016
  • January 2016
  • September 2013
  • July 2013
  • June 2013