Skip to content
ecdsa.com
Microsoft.IdentityModel.Tokens (.NET).NET

Error message

IDX10214: Audience validation failed.

Also printed as

  • IDX10214: Audience validation failed. Audiences: 'api://billing'. Did not match: validationParameters.ValidAudience: 'api://orders' or validationParameters.ValidAudiences: 'null'.
  • Bearer error="invalid_token", error_description="The audience 'api://billing' is invalid"

8.x shortens the text to "IDX10214: Audience validation failed. See https://aka.ms/identitymodel/app-context-switches"; 6.x and 7.x (checked on 6.36.0 and 7.7.1) list the token's audiences and the configured values. ASP.NET Core sends `error_description="The audience '…' is invalid"`.

Microsoft.IdentityModel.Tokens (.NET) — SecurityTokenInvalidAudienceException

What it means

The token's `aud` does not match `ValidAudience` / `ValidAudiences` (or, with `Audience` set on `JwtBearerOptions`, that value). The signature was fine; the token was issued for another recipient. In Microsoft Entra ID the classic mismatch is between the API's App ID URI (`api://…`, used in v1 tokens) and its client ID GUID (used in v2 tokens).

Why it happens

How to fix it

  1. 1.

    List your API's identifiers explicitly

    Accept the client ID and the App ID URI of your API if both token versions are in use — nothing else.

    csharp
    options.TokenValidationParameters = new TokenValidationParameters
    {
        ValidIssuer = "https://login.microsoftonline.com/<tenant-id>/v2.0",
        // Entra ID v2 tokens carry the client ID; v1 tokens the App ID URI. Accept exactly your API's identifiers.
        ValidAudiences = ["00000000-0000-0000-0000-000000000000", "api://orders"],
    };
  2. 2.

    Request a scope of your API

    Tokens for `api://orders/Orders.Read` carry your API as audience. Expose a scope in the app registration and have clients request it.

    csharp
    // Client: request a scope of YOUR API, not Microsoft Graph, so aud is your API.
    var result = await app.AcquireTokenSilent(new[] { "api://orders/Orders.Read" }, account).ExecuteAsync();

Related errors

Browse the full signature error database