Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages

Security and hardening · Troubleshooting walkthrough

Entra ID cannot find the API your app asked a token for

Short answer

AADSTS500011 means Microsoft Entra ID found no service principal for the requested resource inside the tenant that got the request. The API was never added to that tenant, the scope differs from its identifier URI, or the authority names the wrong tenant. Request {identifier URI}/.default from the API's tenant, or run az ad sp create there.

  • Applies to Microsoft identity platform v2.0 endpoint, Microsoft Entra ID (November 2026), Azure CLI 2.93
  • Updated
  • By Maaz Zindani, Senior Software Engineer

AADSTS500011 means Microsoft Entra ID looked for a service principal for the API you asked a token for, inside the tenant that received the request, and found none. A service principal is the tenant's own local record of an application. An API registered in one tenant has no such record in another until someone creates it.

Three different mistakes produce the same code: the API was never installed in the signing-in tenant, the scope string does not match the API's identifier, or the request went to the wrong tenant. One pair of commands tells them apart.

The text you see

  • AADSTS500011: The resource principal named api://my-api was not found in the tenant named <tenant ID>.
  • You might have sent your authentication request to the wrong tenant.

Stage 1

Look the resource up in both tenants

Take the resource name the error quotes, the part before /.default in your scope. Sign in to the tenant named in the error and look it up, then repeat in the tenant where the API is registered.

Is there a service principal in this tenant

az login --tenant <tenant-id-from-the-error> --allow-no-subscriptions
az ad sp show --id "<resource-name-from-the-error>"
  • Found only in the API's own tenant: the API is not installed where users sign in, or the authority points at the wrong tenant.
  • Found nowhere: the scope names a resource that does not exist.

Stage 2

The API is not installed in the signing-in tenant

This is the common case for apps that serve other organisations. The API is registered in one tenant and requested from another, where no administrator provisioned it and no user consented. Without a local service principal Entra ID has nothing to issue a token for. In that tenant the API is absent under Enterprise applications.

A tenant administrator creates the service principal from the API's application (client) ID. Afterwards, open the API under Enterprise applications and grant consent for the permissions your client app requests.

Create the service principal in the customer tenant

az ad sp create --id <api-application-client-id>

Stage 3

The scope names a resource that does not exist

Entra ID takes the resource from the text before /.default and searches for a principal with that identifier. A typo, or an identifier URI renamed after the client was written, fails the search. An identifier registered with a trailing slash needs that slash in the scope too, which gives a double slash before .default.

Copy the identifier, then add /.default

# identifier URI form
scope=api://my-api/.default
# identifier that ends in a slash (Azure Resource Manager)
scope=https://management.azure.com//.default

Stage 4

The authority points at another tenant

Microsoft's troubleshooting steps ask you to compare the tenant in the error with your own tenant ID. A test tenant ID left in production configuration, or an authority copied from another project, sends the request to a directory that never saw the API. Search the code for the tenant ID and the login URL.

Find stray tenant settings

grep -rnE "login.microsoftonline.com|TENANT_ID|tenant_id" --exclude-dir=node_modules .
# corrected authority
https://login.microsoftonline.com/<api-tenant-id>/oauth2/v2.0/authorize

If users really belong to the other tenant, keep that authority and install the API there instead.

Stage 5

Confirm the token is issued

  1. Run az ad sp show --id <api-application-client-id> in the tenant that signs users in; it should now return the API.
  2. Request a token again with the corrected scope or authority and check that an access token comes back.
  3. Add one token request to your deploy smoke test, so a wrong scope fails the release instead of reaching users.

If the token is issued but the API still rejects it, the problem has moved to audience or role validation inside the API, which is a different fix.

If you only keep one thing

  • No service principal in the tenant is the root of AADSTS500011.
  • Check installation, scope text, and tenant ID, in that order.
  • az ad sp create in the target tenant fixes the first case.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Next step

Want a second pair of eyes on it?

Send me the error and what changed before it started. I reply within 24 hours.