-
Notifications
You must be signed in to change notification settings - Fork 643
Apply template with pnp:header or pnp:footer gives error #2732
Comments
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible. |
When I use Fiddler I do see a failed request passing by with status 400 Request
Response
When I use Connect-PnpOnline -UseWebLogin |
@waaromikniet i am also facing same issue with apply-template when header is included in the PnP template, is there any work around ? It is failing when I have Header included in the template, however once received it is working fine but due to not having header, Styles and Site assets like logo are not working ..could you please suggest any workaround that can be applied to by pass this issue and still get Styles and Site assets like logo applied ? Appreciate your help. |
@waaromikniet i removed <pnp:Header Layout="Standard" /> tag from the template and added |
Same issue on my side. If I have Herader or Footer in the template the apply temaplte fails. Also I see another problem when applying <pnp:Theme ... with the template. I suppose they are related issues. |
You could remove the header if you don't need it. But if you need it: If you use the PnP-PowerShell module, the only way is to go back to a release before June 9. If you use PnP-SItes-Core in your custom tooling you could pull the code and make a temporary change in ObjectSiteHeaderSettings.cs. You could remove this section
and replace with
Maybe @PaoloPia or @erwinvanhunen can explain if we need to do some change on tenant level to make this code calling "/_api/web/SetChromeOptions" to work if you use username/password to authenticate because the code seems to fail when you do. I see this check
When this is false code reverts to the old way. I can't pin point what is happening here. I am using the company administrator account to test provisioning. I see checks like
Maybe using company administrator is not supported anymore using username/password? I also tested with an account that is only SharePoint administrator but then the same error. |
@waaromikniet : for my understanding: do you have legacy auth set to false in your tenant settings? If so, PnP PowerShell will use the PnP Management Shell multi-tenant application (if you provided consent to it before you'll find it in the enterprise applications list of your Azure AD, either by the name PnP Management Shell or can be called PnP Office 365 Management Shell). Do other PnP PowerShell cmdlets work as expected? |
@erwinvanhunen Were can I find this setting? You mean this: This is EO and Office. NOt for mobile and desktop app? I am testing on an out of the box E5 developer tenant that I just created. Other PnP-PowerShell commands work as expected. Only when adding pnp:Header or pnp:Footer to my template I get this error. I think because of the code added by @PaoloPia shown above. I don't see any Enterprise applications with the name PNP in my Azure AD. In my azure AD I do see this In usage and insights I see this For the consent. How can I consent when I am using PowerShell? I won't get the consent browser screen when not in interactive mode. |
I have exact same problem when trying to apply SiteFooter xml template to site. Problematic version is SharePointPnPPowerShellOnline 3.24.2008.0. On my other computer I have version 3.19.2003.0 and xml template applies with no problems. Using same account on both computers. |
@waaromikniet You can find the setting by executing Get-SPOTenant or Get-PnPTenant. The setting is called The easiest way to provide consent is by doing:
In your case, as the app is listed as 'interrupted', you might want to remove the entry from your enterprise applications first (I have not seen an 'interrupted' state until now before) |
Added info: setting LegacyAuthProtocolsEnabled to true or false is not instant. That can take a few hours. |
@erwinvanhunen I can't remove the entry from enterprise applications because it is not present in the list. It looks like the code for the header or footer is trying to use oAuth even when in legacy authentication? |
right... okay, so for pure auth, PnP PowerShell will use the legacy auth (SharePointOnlineCredentials) option then. I will check what's exactly happening in the engine when it comes to the headers and footers. There are scenarios where we have to fallback to the Graph or other REST calls and there we need an access token. We utilize a fallback to use the PnP Management Shell OAuth for that. I know for a fact that for the footer we make REST calls, but those are directly towards SharePoint, so there we can utilize the built in ways to acquire an access token for SharePoint (cookie based, etc.), but I'll have to dive a bit deeper into this specific case to see what's going on. |
Have you tried the Connect-PnPOnline -PnPManagementShell -Url option? It will go through the consent flow and add the enterprise app to your AD. You can, after you have consented and not want to have the entry there always remove it again from your AD. |
@erwinvanhunen When I look at the footer code I see the same kind of request being done to /_api/web/SetChromeOptions like in the header code. When I use a footer instead of a header in my template I get the same error. Reverting back to older version of PnP-PowerShell solves the problem. Like mentioned by @ariv8 |
@erwinvanhunen When I perform this and give the app the consent and run my code again I am no longer getting the error. For header or footer. |
Right. So a change has happened that require this consent to be in place. I'll take it up with the team. |
I did some more testing an indeed when you remove the enterprise app the error gets back. I use these 2 lines to apply my template
When I put these 2 lines inside a .ps1 file and run the file I get the error on screen.
When I open a new PowerShell window and manually type these 2 commands the template doesn't get applied but I didn't get the error or any other feedback on screen that the template fails. So when manually typing the command you could get the idea that everything went fine but actually the template fails. We had this problem and thought the template worked but after a week we noticed that nothing had happend on our site. When creating a test .ps1 file we finally noticed the error. |
We have identified the issue and have just merged a solution. We are discussing internally if we should release an intermediate build. |
@erwinvanhunen, is this change present in the august release for PnP PowerShell? |
@erwinvanhunen I'm getting similar issues would you be able to provide an update on this? |
@erwinvanhunen could you please release to correct this issue ? there is an issue when my template contains pnp:header or pnp:footer tag. This error impacts an important project in production. Thanks in advance |
We have narrowed down the issue to a change in the provisioning engine that we unfortunately had to implement. The -current- release of PnP PowerShell and PnP Sites Core will work, however, you have to perform 2 specific steps (only one time): Connect-PnPOnline -Url <yoursite> -PnPManagementShell Authenticate and go through the consent approval, if required (if you have done this before you will not be prompted for consent). Then: Connect-PnPOnline -Graph Again authenticate and provide consent. This will put the right consent in place that the provisioning engine requires to provision the header and footer (and other artifacts that require OAuth based authentication). In the upcoming release of PnP PowerShell we will provide a single cmdlet, |
Hi Erwin,
thanks a lot for your response.
I will test and get back to you
Best regards,
…----- Mail original -----
De: "Erwin van Hunen" <[email protected]>
À: "pnp/PnP-Sites-Core" <[email protected]>
Cc: "colletolivier" <[email protected]>, "Comment" <[email protected]>
Envoyé: Mardi 22 Septembre 2020 16:06:55
Objet: Re: [pnp/PnP-Sites-Core] Apply template with pnp:header or pnp:footer gives error (#2732)
We have narrowed down the issue to a change in the provisioning engine that we unfortunately had to implement. The -current- release of PnP PowerShell and PnP Sites Core will work, however, you have to perform 2 specific steps (only one time):
Connect-PnPOnline - Url < yoursite > - PnPManagementShell
Authenticate and go through the consent approval, if required (if you have done this before you will not be prompted for consent).
Then:
Connect-PnPOnline - Graph
Again authenticate and provide consent.
This will put the right consent in place that the provisioning engine requires to provision the header and footer (and other artifacts that require OAuth based authentication).
In the upcoming release of PnP PowerShell we will provide a single cmdlet, Register-PnPPowerShellAccess that will talk you through the consent steps required for both resources (SharePoint and The Graph).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub , or unsubscribe .
|
Hi,
I Have executed the two command (authentication and consent) but i have always the following isssue :
Apply-PnPProvisioningTemplate : {"odata.error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"fr-FR","value":"Acc\u00e8s refus\u00e9. Vous n\u2019\u00eates
pas autoris\u00e9 \u00e0 effectuer cette action ou \u00e0 acc\u00e9der \u00e0 cette ressource."}}}
At C:\Workspaces\KEOLIS\KEOLIS - KAPRAO\KAPRAO_ProjectSiteProvisioning\Engine\Templates\Projetlys\projet\debug.ps1:23 char:1
+ Apply-PnPProvisioningTemplate -Path "projet-debug.xml" -Parameters @{ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Apply-PnPProvisioningTemplate], Exception
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Provisioning.Site.ApplyProvisioningTemplate
In attachment, the used template and the powershell script executed.
Thanks
Olivier
…----- Mail original -----
De: "Erwin van Hunen" <[email protected]>
À: "pnp/PnP-Sites-Core" <[email protected]>
Cc: "colletolivier" <[email protected]>, "Comment" <[email protected]>
Envoyé: Mardi 22 Septembre 2020 16:06:55
Objet: Re: [pnp/PnP-Sites-Core] Apply template with pnp:header or pnp:footer gives error (#2732)
We have narrowed down the issue to a change in the provisioning engine that we unfortunately had to implement. The -current- release of PnP PowerShell and PnP Sites Core will work, however, you have to perform 2 specific steps (only one time):
Connect-PnPOnline - Url < yoursite > - PnPManagementShell
Authenticate and go through the consent approval, if required (if you have done this before you will not be prompted for consent).
Then:
Connect-PnPOnline - Graph
Again authenticate and provide consent.
This will put the right consent in place that the provisioning engine requires to provision the header and footer (and other artifacts that require OAuth based authentication).
In the upcoming release of PnP PowerShell we will provide a single cmdlet, Register-PnPPowerShellAccess that will talk you through the consent steps required for both resources (SharePoint and The Graph).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub , or unsubscribe .
|
Environment
[X] Office 365 / SharePoint Online
Expected or Desired Behavior
I want to apply this template using Pnp-PowerShell so I am using Apply-PnPProvisioningTemplate
I want my header to be set to compact
Observed Behavior
I am getting the following error'
Apply-PnPProvisioningTemplate : AADSTS65001: The user or administrator has not consented to use the application with ID
'31359c7f-bd7e-475c-86db-fdb8c937548e' named 'PnP Management Shell'. Send an interactive authorization request for thi
s user and resource.
Trace ID: 69ec10b7-0a49-4039-bb8d-a52cd4bf6e00
Correlation ID: f5197f26-24fc-468d-bc87-d2ced9af9fe9
Timestamp: 2020-08-12 14:35:22Z
In my Azure AD I see a interrupted state for application: PnP Management Shell
But that is a non existing app I can't find in the company apps list.
Steps to Reproduce
Install version 3.24.2008.0 of Pnp-PowerShell
Use credential manager with a username and password to connect
Apply my template example on a modern site collection (communication or group site)
Seems almost the same #2537
Same applies when using pnp:Footer
The text was updated successfully, but these errors were encountered: