MuleSoft · JWT Validation policy
401 from the JWT Validation policy
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
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
- Decode the token and note its signing algorithm and claims.
- 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.
- 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.
- 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
→Related errors
- 400 Token was not provided in the requestAn API protected by the JWT Validation policy returns 400 when the request carries no token where the policy looks for it. Send the JWT in the place the policy's JWT Origin and Token Expression settings name.
- 401 Unauthorized or invalid client application credentialsAn API protected by the Client ID Enforcement policy returns 401 when the client application's credentials are missing, invalid or not authorized. The client needs an approved contract for the API and must send matching credentials on every request.
- HTTP:UNAUTHORIZEDHTTP:UNAUTHORIZED means the server rejected the HTTP Request operation because authentication failed or was not provided (HTTP 401). Send the credentials the server expects, and handle the error type if a rejected call is something the flow should survive.
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