[BUG] "Add-PnPApp -Scope Tenant" failing when using App authentication
Reporting an Issue or Missing Feature
When using the following command
Add-PnPApp -Path .\myPackage.sppkg -Scope Tenant -Overwrite
This is FAILING when I use an App Authenticated scope, with the error:
Add-PnPApp: {"odata.error":{"code":"-2130575223, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"Must have Manage Web Site permissions in order to add apps to site collection app catalog"}}}
This however works absolutely fine when using an Interactive login. This was all working absolutely fine for weeks (in a DevOps build pipeline) but has suddenly failed this weekend.
I have checked:
- The certificate thumbprint is correct, and the certificate is both valid and not expired
- the API permissions are App : SharePoint > Sites.FullControl.All and have granted admin consent
- Connected via the App context using a new Terminal (and observed the above error message)
- Connected via interactive context using a new Terminal (and observed it working without issue).
Expected behavior
The app should be added to the Tenant App Catalog
Actual behavior
I get an error message:
Add-PnPApp: {"odata.error":{"code":"-2130575223, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"Must have Manage Web Site permissions in order to add apps to site collection app catalog"}}}
(Yes - I know it is telling me that the error is "Site Collection App Catalog" but the command really was using the "Tenant" scope - screenshot below!)
Steps to reproduce behavior
Connect using an App Authenticated connection.
Use the Add-PnPApp -Scope Tenant command to try and add an SPFx app to the Tenant App Catalog.
What is the version of the Cmdlet module you are running?
3.3.0 (the devops pipeline runs a fresh install each time it runs). Have forced the pipeline to use 3.2.0 but get the same error.
Which operating system/environment are you running PnP PowerShell on?
- [X] Windows
- [X] Linux
Confirmed in a Windows Terminal, and a unix based DevOps pipeline.
Note - things I have tried this morning
- Revoked and re-granted Admin Consent
- Created a brand new App Registration - and set it up from scratch using a new certificate
Same error
Ok - I AM seeing this working in another tenant .. So this is potentially now looking like a tenant level configuration issue.
Question - could this be related to the fact that SharePoint Add-Ins have now been forcibly disabled?
...
Copilot suggested that Get-SPOTenant including IsSharePointAddInsDisabled might be a culprit - suggesting that PnP might be following a code path that requires SharePoint Add-In functionality?
I have been having this very same issue since last week. I still do not know what is causing the issue, but I think it may be related to a change being propagated by Microsoft to all the SharePoint tenants, because this started happening to me in one single tenant, and today I identified this issue in two more tenants.
In my case, I connect to the admin site using the example command below (taken from https://pnp.github.io/powershell/cmdlets/Connect-PnPOnline.html#example-7):
- Connect-PnPOnline -Url "https://contoso.sharepoint.com" -ClientId 6c5c98c7-e05a-4a0f-bcfa-0cfc65aa1f28 -CertificateBase64Encoded $base64encodedstring -Tenant 'contoso.onmicrosoft.com'
Of course, the application has SharePoint > Sites.FullControl.All granted, but when running "Add-PnPApp -Path $Path -Connection $Connection -Scope Tenant -Overwrite -Publish -SkipFeatureDeployment", is when I get the same error.
Any more information is pretty much appreciated since this is causing lots of issues at the moment and probably is getting worse day by day.
I have been having this very same issue since last week. I still do not know what is causing the issue, but I think it may be related to a change being propagated by Microsoft to all the SharePoint tenants, because this started happening to me in one single tenant, and today I identified this issue in two more tenants. ... cont..
Oooh ... that IS interesting .. In that case I'm almost CERTAINLY landing on the side of SharePoint Add-Ins being forcibly disabled as they are pushed out of M365 tenants.
I raised a new Service Request relating to this with M365 support and the default AI generated response was:
This behavior is consistent with a limitation of the Azure AD/Entra app-only model for Tenant App Catalog administration: Microsoft’s documented tenant app catalog admin permission flow for app-only specifically uses the SharePoint add-in/ACS trust model through appregnew.aspx and appinv.aspx on the tenant admin site, not Entra app-only permissions.
So for me this sounds like a slam dunk
@MartinHatchUK we are using the supported (as documented) Entra ID app-only pattern. Can't say this is totally unrelated but we are definitely not using unsupported approach as per documentation so if related to the add-ins retirement in April this for sure should be unexpected by Microsoft.
@VesaJuvonen hopefully you can shed some light as this seems to be a troubling issue that is spreading across tenants now before it gets big enough to mess up all over the place.
Ok, I was about to try using the CLI for Microsoft 365 to discard it was something related to the implementation of the PnP commands. I was going to use M365, but I found there is another issue opened in that GitHub repo: https://github.com/pnp/cli-microsoft365/issues/7454.
Furthermore, this has been confirmed as an issue by MSFT in this other thread where they say this will be handled by the engineering team as a bug: https://github.com/SharePoint/sp-dev-docs/issues/10955.
I guess for now application permission won't be working until they fix it. Using delegated permissions for pipeline automation should not be a thing for production, as it would require an account without MFA.
Yep, got the same issue here. We use tooling that uses app only API permissions with a certificate and our tooling has failed to install with the same error.
Hi, I am having the same issue, Sites.FullControll.All or granted Sites.Selected, with due certificate, which previously were working, today I am facing this issue too.
It looks like the issue is resolved now; at least I can confirm that with the tenants I was working with. They said in the related thread I mentioned before that the issue is solved so the fix must be propagating to all tenants
Is this still an issue ? @MartinHatchUK , not sure if we can do anything here since its a backend change.
According to this, https://github.com/SharePoint/sp-dev-docs/issues/10955 , seems to have been fixed !
Closing this as it is/was a Microsoft issue which has been resolved.