Unable to approve a SPFx app permission request with PnP Powershell
What type of issue is this?
Question
What SharePoint development model, framework, SDK or API is this about?
💥 SharePoint Framework
Target SharePoint environment
SharePoint Online
What browser(s) / client(s) have you tested
- [ ] 💥 Internet Explorer
- [ ] 💥 Microsoft Edge
- [ ] 💥 Google Chrome
- [ ] 💥 FireFox
- [ ] 💥 Safari
- [ ] mobile (iOS/iPadOS)
- [ ] mobile (Android)
- [ ] not applicable
- [ ] other (enter in the "Additional environment details" area below)
Additional environment details
SPFx version 1.18.2 Node 18.9.0 Powershell: 7.4.1 PnP.PowerShell 2.4.33
Issue description
We have some webApiPermissionRequests defined in spfx package-solution json file
"webApiPermissionRequests": [
{
"resource": "Azure AD app name",
"scope": "user_impersonation"
},
{
"resource": "Microsoft Graph",
"scope": "User.Read, AllSites.FullControl"
}
]
In PowerShell I am trying to approve these permission requests using
$permissionRequests = Get-PnPTenantServicePrincipalPermissionRequests
foreach ($req in $permissionRequests)
{
if ($req.PackageName -eq "$muhimbiPackageName")
{
Write-Host "Granting permissions $($req.Name) $($req.Scope)"
Approve-PnPTenantServicePrincipalPermissionRequest -RequestId $req.Id -Force -ErrorAction SilentlyContinue -ErrorVariable approveRequestError -OutVariable approveRequestResult | Out-Null
if (![String]::IsNullOrWhiteSpace($approveRequestError) -And -Not($approveRequestError -imatch "already exists"))
{
Write-Host "approveRequestError: $approveRequestError"
$grantedAllPermissions = $false;
Write-Host "Failed" -ForegroundColor Red
}
else
{
Write-Host "Success" -ForegroundColor Green
}
Write-Host ""
}
}
But I am getting below error:
approveRequestError: The service principal for permssion request {SPFX_App_Name} could not be found.
Please note there is a typo in "permssion"
Script was working fine few days ago but started giving error recently
I tried the SP online powershell as well
Get-SPOTenantServicePrincipalPermissionRequests and Approve-SPOTenantServicePrincipalPermissionRequest
getting same error
Tried
Enable-SPOTenantServicePrincipal it gives us "Unknown Error"
I checked below service principal exists:
- "SharePoint Online Client Extensibility Web Application Principal"
- "GraphAggregatorService" or "Microsoft Graph"
- Azure AD app created by us
Manually approving the permission works just fine
Any updates on this issue? We are having the same problem recently.
Just a +1 also having the same issue, which is a double pain as the web gui also doesn't work (with an MSAL iframe error)
+1 Any updates for this issue?
approveRequestError: The service principal for permssion request {app-name} could not be found.
Failed
+1 Any updates/due dates on this?
Approve-PnPTenantServicePrincipalPermissionRequest : The service principal for permssion request {app name} coul
d not be found.
Get-PnPTenantServicePrincipalPermissionRequests works fine
Hello @mmohapatra-muhimbi, Thank you for bringing this issue to our attention. We will look into it and get back to you shortly. Could you please confirm if the issue still persists for you?
@Amey-MSFT Yes the issue still exists
Hello @mmohapatra-muhimbi, We were able to reproduce the issue, and we are investigating it. We have logged this as a bug, and our engineering team will look into it. Thank you!
+1
Same behavior @dohly noted: Approve-PnPTenantServicePrincipalPermissionRequest : The service principal for permssion request {app name} coul d not be found.
Get-PnPTenantServicePrincipalPermissionRequests works fine
Also unable to approve via: /_layouts/15/online/AdminHome.aspx#/webApiPermissionManagement with error: The requested permission isn't valid. Reject this request and contact the developer to fix the problem and redeploy the solution.
Luckily our existing staging environment approval that has been working for years mysteriously became unapproved. We are trying to add it back. Hope the same doesn't happen in prod :/
Interestingly, package name is "-" in existing approvals, but is the name of the sppkg file now.
This seems to be related to this change in March 2025: https://devblogs.microsoft.com/microsoft365dev/changes-on-sharepoint-framework-spfx-permission-grants-in-microsoft-entra-id/
However this is not rolled out in our tenant yet as we do not see an app registration named: "SharePoint Online Web Client Extensibility"