Dan
Dan

Reputation: 333

Error: AADSTS500011: The resource principal named "URL" was not found in the tenant

I am trying to add an app to our SharePoint Online site using the template from https://learn.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/build-a-hello-world-web-part and we get the error below when we deploy to SharePoint and add the app/Web part to a test SharePoint site. We are using TypeScript as the template uses.

Has anyone else encountered this issue or know where to look for the issue?

Found [object Object]Driver Display External Error: Error: AADSTS500011: The resource principal named https://driverdisplayexternal.azurewebsites.net was not found in the tenant named 7018324c-9efd-4880-809d-b2e6bb1606b6. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You might have sent your authentication request to the wrong tenant. Trace ID: 358b22eb-cd2c-4091-b592-5a57cbc21d00 Correlation ID: ec96d656-1a36-42e2-a2b9-3ff78efc1e2e Timestamp: 2019-10-01 16:26:06Z

We have added a call to our own client as shown below. We are not sure why the resource principal was not found. The Tenant ID's match and things seem to be set up properly for authentication.

HelloWorldWebPart.ts

...
   this.context.aadHttpClientFactory
      .getClient('https://driverdisplayexternal.azurewebsites.net')
      .then((client: AadHttpClient): void => {

        client
          .get('https://driverdisplayexternal.azurewebsites.net/api/values', AadHttpClient.configurations.v1)
          .then((response: HttpClientResponse): Promise < Order[] > => {
            this.domElement.innerHTML += 'Received a response from Driver Display External: ' + response;
            return response.json();
          })

          .catch(error => {

            this.domElement.innerHTML += 'Driver Display External Error:  ' + error;
            console.error(error);
          });
      });
...

package-solution.json

{
  "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
  "solution": {
    "name": "helloworld-webpart-client-side-solution",
    "id": "**ID**",
    "version": "4.1.0.0",
    "includeClientSideAssets": true,
    "isDomainIsolated": false,
    "webApiPermissionRequests": [
      {
        "resource": "DriverDisplayExternal",
       "scope": "User.Read.All"
      }
     ]
  },
  "paths": {
    "zippedPackage": "solution/helloworld-webpart.sppkg"
  }
}

Any help or direction to where the issue may be would be very appreciated. Thanks in advance!

Upvotes: 7

Views: 45401

Answers (5)

Matas Vaitkevicius
Matas Vaitkevicius

Reputation: 61479

In my case, TenantId and ClientId were both ok.

They can be found in AAD. TenantId is right there on landing page:

enter image description here

and then on the same page click Applications then tab All Applications find your application there should be ClientId check if they match.

If that is still not enough, click on the application and find roles

For me, it was roles that were missing after adding those wheels started rolling again:

enter image description here

Upvotes: 0

antoprd
antoprd

Reputation: 403

Sometimes this problem can occurr when you set a wrong name for the scope you are requesting access for or another configuration parameter.

I suggest to check carefully the scopes name, or maybe directly use the "copy" button from the Azure portal.

In my case it was a simple typo on a scope name.

Upvotes: 1

Dimos Dennis
Dimos Dennis

Reputation: 26

In my case i had to use the App Id when i was consuming a multi tenant API.

Upvotes: 0

Verona Chen
Verona Chen

Reputation: 131

Not sure if you figured the answer or not. When you used SPFx to request your own custom web api end point. there are couple steps:

  • request the permission so that you can go to SPO admin to approve the permission you request. for this case, the webApiPermissionRequests->resources needs to your AAD Application's Service Principal DisplayName. once you had AAD App create, you can run Get-AzureADServicePrincipal to get all your ServicePrincipal.
  • once you request the permission, from your code, you need to call AadHttpClient.getClient() to get aadHttpClient object based on the api resourceEndpoint you want, for this case, you need to pass your web api's Application ID URI which can be found from your AAD App's manifest->"identifierUris". General speaking, this should be something like api://[clientid] format. but you can change it to any unique value. I hope it helps.

Upvotes: 0

juunas
juunas

Reputation: 58853

Never used this API, but if I had to guess you need to change the value here:

      .getClient('https://driverdisplayexternal.azurewebsites.net')

You can use either the client id / application id, or the application ID URI.

Upvotes: 2

Related Questions