Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

Entra ID access token has the Microsoft Graph audience instead of my API

Erroraud: 00000003-0000-0000-c000-000000000000

Short answer

The aud claim names the API a token is for, and the scope you request decides it. If the request has no resource in the scope, Microsoft assumes Microsoft Graph, whose id is 00000003-0000-0000-c000-000000000000. Request a scope that belongs to your own API, and have your API accept only tokens with its own audience.

  • Applies to MSAL.js 4, React 19, Microsoft Entra ID
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Decode the access token for debugging only, and read aud and scp. Microsoft documents jwt.ms for this. Do not paste production tokens into other sites.

    # open https://jwt.ms and paste a token from a test account; read the aud and scp claims
  2. 2Match what you see, then jump to its fix

    1. 1Your login request uses scopes such as User.Read or openid only, and the token aud is the Graph idThe scope names no resource, so Graph is assumedFix
    2. 2Your backend rejects the token while Graph itself accepts itThe access token is meant for Graph and your API tries to validate itFix
    3. 3An error about combining scope types, or a token whose aud is a different resource than the one you asked forStatic .default is mixed with other scopes, or points at the wrong resourceFix

What does the error look like?

  • aud: 00000003-0000-0000-c000-000000000000
  • Access token audience is Microsoft Graph, not my API
  • Signature validation of the token fails in my backend

Cause 1 of 3

The scope names no resource, so Graph is assumed

1Check

Microsoft's scope documentation says that if the resource identifier is left out of the scope parameter, the resource is assumed to be Microsoft Graph. So scope=User.Read means https://graph.microsoft.com/User.Read.

grep -rn "scopes" src/ | head

2Fix

Ask for a permission that belongs to your API: the API's application ID URI, a slash, and the scope name you exposed.

// MSAL request object
const request = {
  scopes: ["<application-id-uri>/<scope-name>"],
};

3Verify

Acquire a new token, decode it and confirm that aud is now your API's identifier.

# decode the new token at https://jwt.ms and compare aud with your API's application ID URI

Confirmed by learn.microsoft.com

Did this fix it?

Cause 2 of 3

The access token is meant for Graph and your API tries to validate it

1Check

Microsoft says a web API must accept only tokens that carry one of its own application ID URIs in aud, and that Graph tokens cannot be validated by the normal rules. Accepting a token for another resource is the confused deputy problem.

# in your API: log the aud claim of the rejected token and compare it with your own application ID URI

2Fix

Send your API a token requested for the API's own scope, as above, and keep audience checking on in the API instead of switching it off.

// client: attach the token of the API scope
const result = await instance.acquireTokenSilent({ scopes: ["<application-id-uri>/<scope-name>"], account });
fetch("/api/data", { headers: { Authorization: `Bearer ${result.accessToken}` } });

3Verify

The API accepts the new token and returns data.

curl -H "Authorization: Bearer $TOKEN" https://api.example.com/data

Confirmed by learn.microsoft.com

Did this fix it?

Cause 3 of 3

Static .default is mixed with other scopes, or points at the wrong resource

1Check

The .default scope refers to a whole resource, written as the resource identifier plus /.default. Microsoft's documentation says clients cannot combine that static consent with individual scopes in one request, for example Graph .default together with Mail.Read.

grep -rn "\.default" src/

2Fix

Use one resource per token request. Make a separate request for each API, each with its own scopes.

const apiToken = await instance.acquireTokenSilent({ scopes: ["<application-id-uri>/.default"], account });
const graphToken = await instance.acquireTokenSilent({ scopes: ["User.Read"], account });

3Verify

Decode both tokens and check that each aud matches the resource you wanted.

# decode at https://jwt.ms

Confirmed by learn.microsoft.com

Did this fix it?

How do I stop it coming back?

  • Treat access tokens as opaque in the client and validate only in the API that owns the audience.
  • Request Graph scopes and your own API scopes in separate token requests.
  • Expose the API's scopes in the app registration before the client asks for them.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. 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.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.