# ASP.NET Core API with Auth0: "IDX10609: Decryption failed" when validating tokens from Authorization Code Flow

**URL:** <https://community.auth0.com/t/asp-net-core-api-with-auth0-idx10609-decryption-failed-when-validating-tokens-from-authorization-code-flow/147854>\
**Category:** Get Help\
**Tags:** sdks-quickstarts, auth0net\
**Created:** [September 24, 2024, 3:45am UTC](https://community.auth0.com/t/asp-net-core-api-with-auth0-idx10609-decryption-failed-when-validating-tokens-from-authorization-code-flow/147854 "2024-09-24T03:45:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kartikpat9898](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kartikpat9898/32/60659_2.png) [@kartikpat9898](https://community.auth0.com/u/kartikpat9898)\
**Post date:** [September 24, 2024, 3:45am UTC](https://community.auth0.com/t/asp-net-core-api-with-auth0-idx10609-decryption-failed-when-validating-tokens-from-authorization-code-flow/147854/1 "2024-09-24T03:45:09Z")

</div>

I’m working on an **[ASP.NET](http://ASP.NET) Core API** that uses **Auth0** for authentication and authorization. I’ve run into an issue where my API successfully validates tokens generated using the **Client Credentials Flow** , but fails to validate tokens obtained via the **Authorization Code Flow**. The error I’m getting is:

```auto
Failed to validate the token.
Microsoft.IdentityModel.Tokens.SecurityTokenDecryptionFailedException: IDX10609: Decryption failed. No Keys tried: token: 'null'.
   at Microsoft.IdentityModel.JsonWebTokens.JwtTokenUtilities.ValidateDecryption(...)
   at Microsoft.IdentityModel.JsonWebTokens.JwtTokenUtilities.DecryptJwtToken(...)
   at Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.DecryptToken(...)
   at Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.ValidateJWEAsync(...)

```

**What I’ve Tried So Far:**

1. **Authentication Configuration:**

2. **Ensured Tokens Are Signed, Not Encrypted:**

3. **Obtained New Access Tokens:**

4. **Enabled Detailed Logging and PII:**

5. **Checked Middleware Order:**

**Issue Details:**

- **Client Credentials Tokens Work:** My API successfully validates tokens from the client credentials flow.
- **Authorization Code Tokens Fail:** When using tokens from the authorization code flow, the API throws a decryption failed exception.

**Error Message:**

```auto
Failed to validate the token.
Microsoft.IdentityModel.Tokens.SecurityTokenDecryptionFailedException: IDX10609: Decryption failed. No Keys tried: token: 'null'.
   at Microsoft.IdentityModel.JsonWebTokens.JwtTokenUtilities.ValidateDecryption(...)
   at Microsoft.IdentityModel.JsonWebTokens.JwtTokenUtilities.DecryptJwtToken(...)
   at Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.DecryptToken(...)
   at Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.ValidateJWEAsync(...)

```

**Questions:**

1. **Why is my API trying to decrypt a token that appears to be signed and not encrypted?**
2. **Is there a configuration issue that’s causing the API to treat the token as encrypted?**
3. **Has anyone faced a similar issue where tokens from the authorization code flow fail validation in the API, even though they are correctly signed?**
4. **Are there any additional settings in Auth0 or my application that I should check or adjust?**

**Any guidance or suggestions would be greatly appreciated!**

**Thank you in advance for your help.**

---

<div class="post-metadata">

**Author:** ![reachravik83](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/reachravik83/32/72222_2.png) [@reachravik83](https://community.auth0.com/u/reachravik83)\
**Post date:** [March 21, 2025, 6:11am UTC](https://community.auth0.com/t/asp-net-core-api-with-auth0-idx10609-decryption-failed-when-validating-tokens-from-authorization-code-flow/147854/2 "2025-03-21T06:11:54Z")

</div>

i am facing very similar issue after exchange authorization code with access token. For me Decryption fails since the token that was received after exchange is encrypted. JWE encryption is not enabled in Dashboard still i face this…But you can try adding this IssuerSigningKeyResolver in your code to get the keys from JWKS that might work for you.

thanks

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [April 4, 2025, 6:12am UTC](https://community.auth0.com/t/asp-net-core-api-with-auth0-idx10609-decryption-failed-when-validating-tokens-from-authorization-code-flow/147854/3 "2025-04-04T06:12:03Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
