Error trying to approve a webApiPermissionRequest
- [x] Question
- [ ] Typo
- [ ] Bug
- [ ] Additional article idea
I created a SPFx 1.4.1 based Webpart which uses a custom 3rd party API hosted in an Azure App Service. This Webpart requests permissions as follows:
"webApiPermissionRequests": [
{
"resource": "BusApps",
"scope": "user_impersonation"
}
]
Deploying the App package to the tenant App catalog created a permission request which needs to be approved by a tenant admin. When I login to the new SharePoint Admin center as a global admin I can see the request. When I click on "Approve or reject" the approval dialog opens. If I then click on "approve" I get a not at all helpful error message: "[HTTP]:400 - [CorrelationId]:f2c6539e-6022-5000-2d59-cfc6b8d484f3 [Version]:16.0.0.7507" If I try to approve the request through Powershell (Approve-SPOTenantServicePrincipalPermissionRequest -RequestId 63bf......) then I get a little bit more detail about the actual problem: "An OAuth-Permission with the scope 'user_impersonation' was not found" So there's no way for me to approve this request. Interesting detail: The underlying App registration in AzureAD is set to be "multi tenant". In another tenant I installed the very same Webpart and in that tenant the approval worked without any issues. I have provided admin consent to the App in both tenants and both are set to "target release". I don't know why the tenant in which the App has been created refuses to allow the approval.
Hello, thanks for your feedback. is there a different way you registered the underneath app differently in the two tenants? is the same API ("BusApps") registered as MT in both tenants?
No, I registered the app only in one tenant, that's the reason why we are using multi tenant apps :-) Afterwards I provided admin consent via login.microsoftonline.... to the app in both tenants. The SPFx package has been uploaded to the central app catalog site in both tenants.
Could it be that the AAD app behind your API uses custom scopes rather than the standard user_impersonation? You can verify it in the app's manifest in the AAD.
I haven't changed any scopes in the app manifest. To be honest, I don't even know what that scope is or how to change it. I found this "user_impersonation" string in an example. As I've said, it is a multi-tenant app and it runs without any problems in the second tenant. If you have a link to some kind of documentation of that "scope" thing I'd definitely be interested. It's always good to know what you're doing even if it's most likely not going to help with this issue :-) Two maybe relevant parts of the manifest:
"oauth2Permissions": [
{
"adminConsentDescription": "Allow the application to access BusApps on behalf of the signed-in user.",
"adminConsentDisplayName": "Access BusApps",
"id": "<some id...>",
"isEnabled": true,
"type": "User",
"userConsentDescription": "Allow the application to access BusApps on your behalf.",
"userConsentDisplayName": "Access BusApps",
"value": "user_impersonation"
}
],
"requiredResourceAccess": [
{
"resourceAppId": "00000002-0000-0000-c000-000000000000",
"resourceAccess": [
{
"id": "311a71cc-e848-46a1-bdf8-97ff7156d8e6",
"type": "Scope"
}
]
}
],
As you can see in the code snippet you shared, your API has one permission scope, name user_impersonation defined in its manifest. Whenever you grant another AAD application access to your API, you will be able to grant this permission scope.
Looking at the AAD app manifest, what is the value of the displayName property?
"displayName": "BusApps",
Can you find your BusApps AAD app amongst the known apps in the AAD of the tenant where you want to use it (not in the tenant where you created the app)?
I want to use it in the tenant where I created the app registration but that doesn't work. It works in other tenants though.
not sure if you check your SPO tenant enabled SPO tent service principal? I found out by default it was disabled. if it doesn't, you can run Enable-SPOTenantServicePrincipal to enable that. another way you can verify is to go to your AAD to check if you can find out "SharePoint Online Client Extensibility" Azure AD App.
Hi @cwdata - can you follow up on the last comment from @frankchen76 and if that worked for you.
Sorry for the delayed answer - I'm still on vacation. I don't know if the service principal had already been enabled (it seems there is only enable- and disable-, no get- CmdLet) but I ran the Enable-SPOTenantServicePrincipal CmdLet and it returned "Account enabled: true". But the error still stays the same. It now tells me the reason (OAuth permission "user_impersonation" not found) also in the new admin center. That's the only thing that has changed - probably not because of the service principal being enabled :-)
Approving the permission request is still not working. It should be out of preview in the next weeks so hopefully it will be working in the release version.
From: Douglas Romão [email protected] Send: Montag, 30. Juli 2018 12:30 To: SharePoint/sp-dev-docs [email protected] Subject: Re: [SharePoint/sp-dev-docs] Error trying to approve a webApiPermissionRequest (#1477)
Are you guys still having this issue? I'm trying to use the webApiPermissionRequest but I'm getting the same error message.
Hi, @cwdata thanks for the reply! Let's wait then.
It seems we are facing the exact same issue with SPFx 1.6.0 after GA. As long as we use multi-tenant configuration as described in the official documentation AND the Azure function is hosted/registered in a different AzureAD tenant than the SPO it works. When it is the same it doesn't work as mentioned above with same error. Even when I recreate the Azure Function in the same tenant without enabling multi-tenant I now face that error. Any further ideas?
Hi @cwdata , @mmsharepoint @VesaJuvonen , I have the same problem so any idea to resolve.
Which exact same error do you have @mrphannguyen ? As here are mentioned slightly differen issues. In my case it turned out the following: I registered the app for several stages several times following the "multi-tenant" Microsoft tutorial approach. Unfortunately in one case it is not really "multi tenant" meaning Azure Function, App AND Office365 running in same subscription/Azure AD. In that case I had top delete the app and re-register the simple (non-multi-tenant) tutorial approach. I ALSO had to use a different name than the origin one (or should have waited longer than ~a day after deletion? Was not patient ;-) )
To be precise: Here the link I am talking about with the MS multi tenant scenario https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-aadhttpclient-enterpriseapi-multitenant
And here quite the same (only small differences) for within a single tenant (Azure Function is hosted in same Azure Subscriotion/AzureAD than your O365 tenant) https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-aadhttpclient-enterpriseapi
Hi @mmsharepoint , I created a SPFx 1.6.0 based Webpart which uses a custom 3rd party API hosted in an Azure App Service. Here: "webApiPermissionRequests": [{ "resource": "QS PortalTalk", "scope": "user_impersonation" }] We have 7 tenants are using the webpart but has 1 tenant can not approve the web API permission above in API management with the following error:
[HTTP]:400 - [CorrelationId]:c0019d9e-4000-7000-40be-60a008225b5d [Version]:16.0.0.8210 - An OAuth permission with the scope user_impersonation could not be found. Parameter name: scope
But other tenants are ok.
@mrphannguyen, let me guess: That one tenant where you get the error is the one where you have registered the multi-tenant AzureAD Application for your App Service?
No @cwdata, that one tenant is a customer of our App service
@mrphannguyen But which way did you follow, the "multi-tenant" way? My solution and scenario I showed above, if your case is different you should first try to find differences between that one tenant/scenario and the others. Otherwise we cannot guess an indication maybe there is an unknown similarity to our scenario? Best Markus