MuleSoft · JWT Validation policy

401 from the JWT Validation policy

Short answer

An API protected by the JWT Validation policy returns 401 when the token's signature is invalid, a required claim is missing or fails validation, or the token cannot be parsed. Compare the token with the policy's signing method, key and claim settings.

VerifiedLast verified

01Error text

MuleSoft error
401 - Signature was not validated, or is invalid. / Some of the required claims are not present or their validation failed. / Failed to parse the token.

02Likely causes

  • Signature was not validated, or is invalid.
  • Some of the required claims are not present or their validation failed.
  • Failed to parse the token.
  • If the signing algorithm set in the policy does not match the token's, all JWTs are rejected.

03How to fix it

  1. Decode the token and note its signing algorithm and claims.
  2. In the policy configuration, check JWT Signing Method, JWT Signing Key Length and the key source (JWT Key Origin, JWT Key or JWKS URL) against the token issuer.
  3. Check the claim settings: Validate Audience Claim, Validate Expiration Claim, Validate Not Before Claim and Validate Custom Claim, and Client ID Expression unless Skip Client ID Validation is on.
  4. Send a token that satisfies those settings.

iNotes

The docs list the three causes but give no resolution steps for them. The steps above check each documented setting in turn.

04Official documentation

Test every fix in a non-production environment before you apply it to production. See how entries are verified.

More for MuleSoft work:Open MuleSoft jobsMuleSoft rates and salariesHire a senior MuleSoft developer

The iPaaS Brief

Subscribe to The iPaaS Brief.

The iPaaS newsletter for the people who run integrations. From iPaaS Group.

Free. You finish on theipaasbrief.com and confirm by email.