SharePoint / SharePoint/sp-dev-docs
Unable to approve a SPFx app permission request with PnP Powershell
@Amey-MSFT is already working on this.
Since Jun 23, 2025.
- Dominant language
- PowerShell
- Stars
- 1.4k
- Forks
- 1.1k
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 12
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.