Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to approve a SPFx app permission request with PnP Powershell #9633

Open
9 tasks
mmohapatra-muhimbi opened this issue Apr 11, 2024 · 2 comments
Open
9 tasks
Labels
Needs: Triage 🔍 Awaiting categorization and initial review.

Comments

@mmohapatra-muhimbi
Copy link

mmohapatra-muhimbi commented Apr 11, 2024

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:

  1. "SharePoint Online Client Extensibility Web Application Principal"
  2. "GraphAggregatorService" or "Microsoft Graph"
  3. Azure AD app created by us

Manually approving the permission works just fine

@tomaszoida
Copy link

Any updates on this issue? We are having the same problem recently.

@marcus-atvero
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Triage 🔍 Awaiting categorization and initial review.
Projects
None yet
Development

No branches or pull requests

4 participants