pnp / pnpframework

PnP Framework is a .NET library targeting Microsoft 365 containing the PnP Provisioning engine and a ton of other useful extensions
https://pnp.github.io/pnpframework/
MIT License
211 stars 145 forks source link

Invoke-PnPTenantTemplate - AADSTS70011: The provided request must include a 'scope' input parameter. #1082

Open arnieraju opened 2 weeks ago

arnieraju commented 2 weeks ago

Suddenly getting consistent 401 Unauthorised errors from PnP.Framework when applying a template to a new site. Template has worked fine in the last couple of weeks. This issue just started today.

Reproduced in PowerShell 7.4.5 and 7.4.6 with PnP 2.12.0 on Windows and Mac, and on 2 different development tenancies using these steps:

Connect-PnPOnline as user with SPO Admin Role using -interactive. This connects successfully without any issues.

Set-PnPTraceLog to Debug Invoke-PnPTenantTemplate PowerShell Progress bar indicates "Applying template to tenant [Sequences]" New PnP Auth popup appears with this message:

image image

Debug level trace output is below.

pwsh Information: 0 : 2024-11-06 14:58:45.4807  [GetContextAsync]   [0] [Debug] Authentication type: AzureADInteractive for scopes https://***********-admin.sharepoint.com/.default    0ms 
pwsh Information: 0 : 2024-11-06 14:59:02.3087  [PnP.Framework] [0] [Debug] Cloning context for https://***********-admin.sharepoint.com/   0ms 
pwsh Information: 0 : 2024-11-06 14:59:02.3098  [PnP.Framework] [0] [Debug] Checking for different audience https://***********-admin.sharepoint.com/   0ms 
pwsh Information: 0 : 2024-11-06 14:59:02.3563  [PnP.Framework] [0] [Information]   File precontract-provisioning.xml retrieved from folder     0ms 
pwsh Information: 0 : 2024-11-06 14:59:02.3577  [PnP.Framework] [0] [Information]   File precontract-provisioning.xml retrieved from folder     0ms 
pwsh Information: 0 : 2024-11-06 14:59:02.4452  [PnP.Framework] [0] [Information]   File Templates/urban-site-template.xml retrieved from folder    0ms 
pwsh Information: 0 : 2024-11-06 14:59:02.4533  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/site-settings.xml retrieved from folder    0ms 
pwsh Information: 0 : 2024-11-06 14:59:02.4542  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/regional-settings.xml retrieved from folder    0ms 
pwsh Information: 0 : 2024-11-06 14:59:02.4545  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/propertybags.xml retrieved from folder     0ms 
pwsh Information: 0 : 2024-11-06 14:59:02.4547  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/navigation.xml retrieved from folder   0ms 
pwsh Information: 0 : 2024-11-06 14:59:02.4551  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/features.xml retrieved from folder     0ms 
pwsh Information: 0 : 2024-11-06 14:59:02.4554  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/client-side-pages.xml retrieved from folder    0ms 
pwsh Information: 0 : 2024-11-06 14:59:02.4568  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/files.xml retrieved from folder    0ms 
pwsh Information: 0 : 2024-11-06 14:59:02.4570  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/header.xml retrieved from folder   0ms 
pwsh Information: 0 : 2024-11-06 14:59:03.3849  [PnP.Framework] [0] [Information]   File Templates/civil-site-template.xml retrieved from folder    0ms 
pwsh Information: 0 : 2024-11-06 14:59:03.3906  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/site-settings.xml retrieved from folder    0ms 
pwsh Information: 0 : 2024-11-06 14:59:03.3910  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/regional-settings.xml retrieved from folder    0ms 
pwsh Information: 0 : 2024-11-06 14:59:03.3913  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/propertybags.xml retrieved from folder     0ms 
pwsh Information: 0 : 2024-11-06 14:59:03.3914  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/navigation.xml retrieved from folder   0ms 
pwsh Information: 0 : 2024-11-06 14:59:03.3917  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/features.xml retrieved from folder     0ms 
pwsh Information: 0 : 2024-11-06 14:59:03.3918  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/client-side-pages.xml retrieved from folder    0ms 
pwsh Information: 0 : 2024-11-06 14:59:03.3934  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/files.xml retrieved from folder    0ms 
pwsh Information: 0 : 2024-11-06 14:59:03.3937  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/header.xml retrieved from folder   0ms 
pwsh Information: 0 : 2024-11-06 14:59:03.6058  [PnP.Framework] [0] [Information]   File Templates/mining-site-template.xml retrieved from folder   0ms 
pwsh Information: 0 : 2024-11-06 14:59:03.6112  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/site-settings.xml retrieved from folder    0ms 
pwsh Information: 0 : 2024-11-06 14:59:03.6115  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/regional-settings.xml retrieved from folder    0ms 
pwsh Information: 0 : 2024-11-06 14:59:03.6117  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/propertybags.xml retrieved from folder     0ms 
pwsh Information: 0 : 2024-11-06 14:59:03.6119  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/navigation.xml retrieved from folder   0ms 
pwsh Information: 0 : 2024-11-06 14:59:03.6122  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/features.xml retrieved from folder     0ms 
pwsh Information: 0 : 2024-11-06 14:59:03.6124  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/client-side-pages.xml retrieved from folder    0ms 
pwsh Information: 0 : 2024-11-06 14:59:03.6136  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/files.xml retrieved from folder    0ms 
pwsh Information: 0 : 2024-11-06 14:59:03.6138  [PnP.Framework] [0] [Information]   File ./Templates/Includes/Common/header.xml retrieved from folder   0ms 
pwsh Information: 0 : 2024-11-06 14:59:04.2896  [GetAccessTokenAsync]   [0] [Debug] Authentication type: AzureADInteractive 0ms 
pwsh Information: 0 : 2024-11-06 14:59:04.6326  [GetAccessTokenAsync]   [0] [Debug] Authentication type: AzureADInteractive 0ms 
pwsh Information: 0 : 2024-11-06 14:59:04.8115  [PnP.Framework] [0] [Debug] ApplyTenantTemplate 0ms 
pwsh Information: 0 : 2024-11-06 14:59:04.8158  [Provisioning]  [16]    [Debug] Code execution scope started    0ms 0f7e06b3-f9aa-4fb2-9d4a-bc4c9ebf9e54
pwsh Information: 0 : 2024-11-06 14:59:04.8164  [Provisioning]  [16]    [Information]   ProgressDelegate registered 1ms 0f7e06b3-f9aa-4fb2-9d4a-bc4c9ebf9e54
pwsh Information: 0 : 2024-11-06 14:59:04.8167  [Provisioning]  [16]    [Information]   MessagesDelegate registered 1ms 0f7e06b3-f9aa-4fb2-9d4a-bc4c9ebf9e54
pwsh Information: 0 : 2024-11-06 14:59:04.8167  [PnP.Framework] [0] [Debug] Attaching object handlers   0ms 
pwsh Information: 0 : 2024-11-06 14:59:05.2153  [PnP.Framework] [0] [Debug] Cloning context for https://***********-admin.sharepoint.com/   0ms 
pwsh Information: 0 : 2024-11-06 14:59:05.2156  [PnP.Framework] [0] [Debug] Checking for different audience https://***********-admin.sharepoint.com/   0ms 
pwsh Information: 0 : 2024-11-06 14:59:05.3203  [PnP.Framework] [0] [Debug] Cloning context for https://***********-admin.sharepoint.com/   0ms 
pwsh Information: 0 : 2024-11-06 14:59:05.3205  [PnP.Framework] [0] [Debug] Checking for different audience https://***********-admin.sharepoint.com/   0ms 
pwsh Information: 0 : 2024-11-06 14:59:05.3933  [PnP.Framework] [0] [Debug] Cloning context for https://***********-admin.sharepoint.com/   0ms 
pwsh Information: 0 : 2024-11-06 14:59:05.3934  [PnP.Framework] [0] [Debug] Checking for different audience https://***********-admin.sharepoint.com/   0ms 
pwsh Information: 0 : 2024-11-06 14:59:05.7252  [PnP.Framework] [0] [Debug] Cloning context for https://***********-admin.sharepoint.com/   0ms 
pwsh Information: 0 : 2024-11-06 14:59:05.7256  [PnP.Framework] [0] [Debug] Checking for different audience https://***********-admin.sharepoint.com/   0ms 
pwsh Information: 0 : 2024-11-06 14:59:05.8110  [PnP.Framework] [0] [Debug] Cloning context for https://***********-admin.sharepoint.com/   0ms 
pwsh Information: 0 : 2024-11-06 14:59:05.8114  [PnP.Framework] [0] [Debug] Checking for different audience https://***********-admin.sharepoint.com/   0ms 
pwsh Information: 0 : 2024-11-06 14:59:05.9014  [ProvisioningTemplate WebHook Call] [16]    [Debug] Code execution scope started    10ms    0f7e06b3-f9aa-4fb2-9d4a-bc4c9ebf9e54
pwsh Information: 0 : 2024-11-06 14:59:05.9034  [ProvisioningTemplate WebHook Call] [16]    [Debug] Code execution scope ended  11ms    0f7e06b3-f9aa-4fb2-9d4a-bc4c9ebf9e54
pwsh Information: 0 : 2024-11-06 14:59:05.9221  [Provisioning]  [16]    [Debug] Code execution scope started    0ms 0f7e06b3-f9aa-4fb2-9d4a-bc4c9ebf9e54
pwsh Information: 0 : 2024-11-06 14:59:06.9305  [PnP.Framework] [0] [Debug] Cloning context for https://***********.sharepoint.com/ 0ms 
pwsh Information: 0 : 2024-11-06 14:59:06.9325  [PnP.Framework] [0] [Debug] Checking for different audience https://***********.sharepoint.com/ 0ms 
pwsh Information: 0 : 2024-11-06 14:59:06.9329  [PnP.Framework] [0] [Debug] Setting up context for different audience AzureADInteractive    0ms 
pwsh Information: 0 : 2024-11-06 14:59:06.9338  [GetContextAsync]   [0] [Debug] Authentication type: AzureADInteractive for scopes https://***********.sharepoint.com/.default  0ms 
pwsh Information: 0 : 2024-11-06 14:59:07.1850  [PnP.Framework] [0] [Debug] GetGroupInfoAsync   0ms 
pwsh Information: 0 : 2024-11-06 14:59:07.1853  [PnP.Framework] [0] [Debug] GetWebUrl   0ms 
pwsh Information: 0 : 2024-11-06 14:59:07.3772  [PnP.Framework] [0] [Debug] AuthenticateRequestAsync    0ms 
pwsh Information: 0 : 2024-11-06 14:59:07.3846  [GetAccessTokenAsync]   [0] [Debug] Authentication type: AzureADInteractive 0ms 
pwsh Information: 0 : 2024-11-06 14:59:08.3622  [GetAccessTokenAsync]   [0] [Debug] Authentication type: AzureADInteractive 0ms 

Applying template to tenant [Sequences                                                                               ]

/

arnieraju commented 2 weeks ago

It appears this issue applies to the -Interactive auth method - I have been able to workaround this using a certificate for for authentication.

SuperYoda3000 commented 1 week ago

I get this same issue when running a Invoke-PnPSiteTemplate command. The error pops up when the cmdlet says "Applying template to https:///sites. [ClientSidePages". The odd thing is this does not happen with our test tenant. The only difference as far as I know is the test tenant does not have a vanity url, whereas our prod tenant does.

image