Skip to content

Commit 55d2a2d

Browse files
authored
Merge pull request #9037 from genlin/main5976
AB#5976 token-signature-validation-error
2 parents 1ba3e34 + 94a02d0 commit 55d2a2d

File tree

2 files changed

+117
-0
lines changed

2 files changed

+117
-0
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
---
2+
title: How to Resolve Token Signature Validation Errors in Microsoft Entra ID Applications
3+
description: This article discusses how to resolve IDX10501 Signature Validation Errors in Microsoft Entra ID applications.
4+
ms.date: 06/03/2025
5+
author: genlin
6+
ms.author: bachoang
7+
ms.service: entra-id
8+
ms.custom: sap:Developing or Registering apps with Microsoft identity platform
9+
---
10+
# IDX10501 Signature Validation Errors in Microsoft Entra ID applications
11+
12+
If a client application obtains an access token from Microsoft Entra ID and sends it to a resource (API) application, the resource application must validate the token. It validates by using the public key from the certificate that was used to sign the token. If the application can't find the correct key identifier (kid), it might generate an error message that resembles the following message:
13+
14+
> IDX10501: Signature validation failed. Unable to match 'kid'
15+
16+
To resolve token signature validation errors such as "IDX10501," make sure that your application is configured to retrieve the correct public key from Microsoft Entra ID. Use the appropriate key discovery or metadata endpoint, based on the application type and signing configuration.
17+
18+
## For OAuth2 resource applications
19+
20+
The following steps demonstrate how an OAuth2 application validates a token that's issued from Microsoft Entra ID:
21+
22+
1. Use an API client to perform an [Authorization Code flow](/entra/identity-platform/v2-oauth2-auth-code-flow) and acquire a token.
23+
1. Decode the token by using [jwt.ms](https://jwt.ms), and note the `kid`.
24+
1. Depending on your Microsoft Entra ID application version, use the token as a bearer token to call one of the following keys discovery endpoints. The API returns three keys. The `kid` that you obtained in step 2 should match one of the keys that are returned by the keys discovery endpoint.
25+
26+
For v1.0 applications, use:
27+
28+
```http
29+
https://login.microsoftonline.com/common/discovery/keys
30+
```
31+
32+
For v2.0 applications, use:
33+
34+
```http
35+
https://login.microsoftonline.com/common/discovery/v2.0/keys
36+
```
37+
38+
## For SAML resource applications
39+
40+
For SAML, Microsoft Entra ID uses the app-specific certificate to sign tokens. To retrieve the correct public key, follow these steps:
41+
42+
1. Use the API client to acquire an access token for the SAML app.
43+
2. Use the following keys discovery endpoint, replacing `<tenant>` and `<SAML App ID>` with your values.
44+
45+
```http
46+
https://login.microsoftonline.com/<tenant>/discovery/keys?appid=<SAML App ID>
47+
```
48+
3. If your app uses custom signing keys that use a [claims-mapping policy](/entra/identity-platform/saml-claims-customization), you must append an `appid` query parameter that contains the app client ID. This step is necessary to retrieve a `jwks_uri` that points to the app’s specific signing key information. For example:
49+
50+
```http
51+
https://login.microsoftonline.com/{tenant}/v2.0/.well-known/openid-configuration?appid=6731de76-14a6-49ae-97bc-6eba6914391e
52+
```
53+
54+
### Middleware configuration examples
55+
56+
To avoid signature validation errors, configure your middleware to use the correct metadata endpoint.
57+
58+
**OpenID Connect Middleware (OWIN)**
59+
60+
```csharp
61+
app.UseOpenIdConnectAuthentication(
62+
new OpenIdConnectAuthenticationOptions
63+
{
64+
ClientId = clientId,
65+
Authority = authority,
66+
RedirectUri = redirectUri,
67+
MetadataAddress = "https://login.microsoftonline.com/<tenant>/.well-known/openid-configuration?appid=<SAML App ID>",
68+
PostLogoutRedirectUri = redirectUri,
69+
});
70+
```
71+
72+
**JWT Bearer Authentication Middleware**
73+
74+
```csharp
75+
app.UseJwtBearerAuthentication(new JwtBearerOptions
76+
{
77+
Audience = "...",
78+
Authority = "...",
79+
MetadataAddress = "https://login.microsoftonline.com/<tenant>/.well-known/openid-configuration?appid=<SAML App ID>",
80+
TokenValidationParameters = new TokenValidationParameters
81+
{
82+
// Additional validation parameters
83+
}
84+
});
85+
```
86+
87+
**Microsoft.Identity.Web (Web App)**
88+
89+
```csharp
90+
services.AddMicrosoftIdentityWebAppAuthentication(Configuration)
91+
.EnableTokenAcquisitionToCallDownstreamApi()
92+
.AddInMemoryTokenCaches();
93+
94+
services.Configure<MicrosoftIdentityOptions>(options =>
95+
{
96+
options.MetadataAddress = "https://login.microsoftonline.com/<tenant>/.well-known/openid-configuration?appid=<SAML App ID>";
97+
});
98+
```
99+
100+
**Microsoft.Identity.Web (Web API)**
101+
102+
```csharp
103+
services.AddMicrosoftIdentityWebApiAuthentication(Configuration);
104+
105+
services.Configure<JwtBearerOptions>(JwtBearerDefaults.AuthenticationScheme, options =>
106+
{
107+
options.MetadataAddress = "https://login.microsoftonline.com/<tenant>/.well-known/openid-configuration?appid=<SAML App ID>";
108+
});
109+
```
110+
111+
## Next steps
112+
113+
To learn more about Microsoft the Entra ID signing keys rollover, see [Access tokens in the Microsoft identity platform](/entra/identity-platform/access-tokens).
114+
115+
[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)]

support/entra/entra-id/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
href: app-integration/asp-dot-net-application-infinite-sign-in-loop.md
7070
- name: Package Inspector for MSAL Android Native
7171
href: app-integration/package-inspector-msal-android-native.md
72+
- name: Unable to match key ID
73+
href: app-integration/idx10501-token-signature-validation-error.md
7274
- name: Repeated login prompts in iOS MSAL implementation
7375
href: app-integration/repeat-login-prompts-in-msal-ios-app.md
7476
- name: Sign out of OpenID Connect/OAuth2 applications without a user selection prompt

0 commit comments

Comments
 (0)