PnP-Sites-Core
PnP-Sites-Core copied to clipboard
[BUG] Apply-PnPProvisioningTemplate: [Error] Creating view failed: Your template contains artifacts that require an access token - occurring when using {res:[key]} in the DisplayName property of the view
Environment
[X] Office 365 / SharePoint Online [ ] SharePoint 2016 [ ] SharePoint 2013
Running SharePointPnPPowerShellOnline 3.25.2009.1
Expected or Desired Behavior
I'm trying to create a list with the following call: Apply-PnPProvisioningTemplate -Path $xmlFilePath -Handlers 'Lists', 'Fields', 'SupportedUILanguages'
I expect the list view name to be properly translated for each of the languages provided in the Localizations XML node.
Observed Behavior
It fails with this error (see full error message at the bottom):
PowerShell_ISE.exe Error: 0 : 2020-09-09 16:49:23.2552 [List instances] [17] [Error] Creating view failed: Your template contains artifacts that require an access token. Please provide consent to the PnP
Management Shell application first by executing: Connect-PnPOnline -Graph -LaunchBrowser
I an tenant admin, and have also tried to run "Connect-PnPOnline -Graph -LaunchBrowser" and logged in, but still get the error.
The template file only contains one single list with no additional fields and only one view where the view DisplayName property is like this: DisplayName="{res:ListView_TEST_All_Items_Title}"
I have two Localizations (English and Norwegian) and the resx-files only contains one single translated value for the single view in the xml file like this:
<data name="ListView_TEST_All_Items_Title" xml:space="preserve">
<value>Test list name translation English</value>
</data>
Steps to Reproduce
Use the attached xml and resx files to try to create the list.
Error message from Debug output in PowerShell
PowerShell_ISE.exe Information: 0 : 2020-09-09 17:02:37.4702 [List instances] [17] [Debug] Creating view {res:ListView_TEST_All_Items_Title} 1660ms 1881cd98-1361-4ce0-a7b7-f7849f53a9f9
PowerShell_ISE.exe Error: 0 : 2020-09-09 17:02:38.2158 [List instances] [17] [Error] Creating view failed: Your template contains artifacts that require an access token. Please provide consent to the PnP
Management Shell application first by executing: Connect-PnPOnline -Graph -LaunchBrowser : at PnP.PowerShell.Commands.Provisioning.Site.ApplyProvisioningTemplate.<>c.<<ExecuteCmdlet>b__16_3>d.MoveNex
t()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.PnPProvisioningContext.AcquireToken(String resource, String scope)
at Microsoft.SharePoint.Client.ClientContextExtensions.GetAccessToken(ClientRuntimeContext clientContext)
at Microsoft.SharePoint.Client.ClientContextExtensions.IsAppOnly(ClientRuntimeContext clientContext)
at OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.Extensions.LocalizationExtensions.CanUseAcceptLanguageHeaderForLocalization(Web web)
at OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.Extensions.LocalizationExtensions.LocalizeView(View view, Web web, String token, TokenParser parser, PnPMonitoredScope scope)
at OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.ObjectListInstance.CreateView(Web web, View view, ViewCollection existingViews, List createdList, PnPMonitoredScope monitoredScope, TokenPars
er parser, Int32 currentViewIndex, Int32 total) 2405ms 1881cd98-1361-4ce0-a7b7-f7849f53a9f9
PowerShell_ISE.exe Information: 0 : 2020-09-09 17:02:38.2178 [List instances] [17] [Debug] Code execution scope ended 2408ms 1881cd98-1361-4ce0-a7b7-f7849f53a9f9
PowerShell_ISE.exe Information: 0 : 2020-09-09 17:02:38.2188 [ProvisioningTemplate WebHook Call] [17] [Debug] Code execution scope started 0ms 1881cd98-1361-4ce0-a7b7-f7849f53a9f9
PowerShell_ISE.exe Information: 0 : 2020-09-09 17:02:38.2198 [ProvisioningTemplate WebHook Call] [17] [Debug] Code execution scope ended 0ms 1881cd98-1361-4ce0-a7b7-f7849f53a9f9
PowerShell_ISE.exe Information: 0 : 2020-09-09 17:02:38.2198 [Provisioning] [17] [Debug] Code execution scope ended 4924ms 1881cd98-1361-4ce0-a7b7-f7849f53a9f9
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
We are seeing the exact same issue.
I connected using username and password (stored with Add-PnPStoredCredential) and then tried applying the template and received this message:
Apply-PnPProvisioningTemplate : Please provide consent to the PnP Management Shell application with 'Register-PnPManagementShellAccess' and follow the steps on screen.
After doing that (and trying to apply the template to a STS#0 site), it worked fine:
I'm seeing this today as well. I think I narrowed it down to the following line in my template:
<pnp:Header Layout="Standard" />
When that line is in my template, I get the error:
Apply-PnPProvisioningTemplate : Please provide consent to the PnP Management Shell application with 'Register-PnPManagementShellAccess' and follow the steps on screen.
At line:1 char:1
+ Apply-PnPProvisioningTemplate `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Apply-PnPProvisioningTemplate], PSInvalidOperationException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Provisioning.Site.ApplyProvisioningTemplate
Without that line, no error.
I'm using the October 2020 release.
Hi, Unfortunately I don't have any such line in my template. In my test I don't get the error if I remove the translation of the list view DisplayName property.
Alexander
Removing <pnp:Header Layout="Standard" /> fixed the error for me too.
I am seeing this when the "<pnp:Footer " section is present as well
I just hit that error again after removing <pnp:Header Layout="Standard" />. I removed <pnp:Footer as well and that fixed it.
I ran into that error, too. In my case it occures if the template contains the <pnp:ApplicationLifecycleManagement>
tag.