A JWT decoder can make API troubleshooting faster, but reading a token is not the same as trusting it. This guide provides a practical workflow for inspecting claims safely, validating signatures and registered claims, and deciding when an authentication failure requires changes to the client, identity provider, or API.
Overview
JSON Web Tokens (JWTs) are compact tokens commonly used to carry claims between an identity provider, a client, and an API. A signed JWT usually contains three Base64URL-encoded parts separated by periods: a header, a payload, and a signature. The header describes the token type and signing algorithm; the payload contains claims; and the signature allows a verifier to check whether the signed content was altered.
A JWT decoder online or a local decoding utility can display the header and payload without proving that the token is authentic. Decoding is therefore useful for debugging, but decoded values must be treated as untrusted input until the signature and relevant validation rules have passed. If a token has an encrypted format rather than a readable signed payload, decoding alone may not reveal its contents.
Keep these three activities separate:
- Decode: Read the token's encoded structure and claims.
- Verify: Check the signature with the expected key and an explicitly allowed algorithm.
- Authenticate: Apply application rules such as issuer, audience, time, scope, and subject checks before authorizing a request.
For a broader troubleshooting sequence, see the JWT Debugging Guide. The checklist below is designed for repeat use during API authentication investigations.
Common JWT claims
| Claim | Typical purpose | What to check |
|---|---|---|
iss | Token issuer | Matches the identity provider configured for the API. |
sub | Subject or principal | Maps to the expected user, service, or client identity. |
aud | Intended recipient | Includes the API or resource server's expected audience. |
exp | Expiration time | Has not passed, accounting for a deliberately configured clock tolerance. |
nbf | Not-before time | Is not later than the verifier's current time. |
iat | Issued-at time | Is plausible for the request and useful for comparing token age. |
scope or roles | Permissions or entitlements | Matches the API's authorization model and expected naming. |
Checklist by scenario
When a request returns 401 Unauthorized
- Confirm that the client sent the expected
Authorization: Bearerheader and that no logging or proxy layer removed or rewrote it. - Decode the token locally or in an approved, non-production-safe environment. Check that it has the expected three-part structure and that the payload is readable JSON.
- Compare
issandaudwith the API configuration. A valid token issued for another resource is still unsuitable for this API. - Check
expandnbf, then investigate clock differences between the client, API, and identity provider if the times appear reasonable but validation fails. - Verify the signature using the identity provider's trusted key material and the server-side JWT library. Do not treat a successful decode as successful verification.
When a request returns 403 Forbidden
A 403 response commonly indicates that the API recognized the caller but rejected the requested action. Inspect scope, roles, groups, or application-specific permission claims, then compare them with the endpoint's authorization requirement. Also confirm that the API is reading the claim name and value format you expect. A role called admin, for example, is not automatically equivalent to a scope named records:write.
When comparing tokens from two environments
Use the same checklist for both tokens and record differences in issuer, audience, subject, expiration, scopes, tenant or organization identifiers, and key identifiers such as kid. Do not conclude that a token is defective solely because claim order or optional claims differ. Compare the API's contract and validation configuration instead.
When debugging an identity-provider integration
Confirm that the client requested the intended resource or audience, that the API trusts the correct issuer, and that the verifier can obtain the matching public key. If keys rotate, the API must use a supported key-discovery and caching approach rather than relying indefinitely on one copied key. Keep access tokens, refresh tokens, and identity tokens distinct: their intended consumers and claims can differ.
What to double-check
- Algorithm handling: Configure the verifier with an explicit allowlist appropriate to the deployment. Do not select a verification method solely from an untrusted header or accept an algorithm the application does not expect.
- Key selection: Treat
kidas a lookup hint, not proof that a key is trusted. The issuer and trusted key source must be established by configuration. - Audience semantics: Confirm whether the library expects a string, a list, or another representation for
aud. Validate the exact intended recipient. - Time validation: Check units and formats. JWT time claims are generally numeric date values, and a seconds-versus-milliseconds mistake can make otherwise valid tokens appear expired or not yet active.
- Authorization boundaries: Signature verification proves integrity and possession of a signing-authorized token; it does not grant access to every endpoint.
- Logging: Redact the complete token and sensitive claims from application logs, tickets, screenshots, chat messages, and browser history. Prefer a token fingerprint or selected non-sensitive metadata when correlating requests.
For production systems, validation belongs in the API's trusted server-side security layer, not in a browser-only check. Client-side decoding can support interface behavior, but it must never be the sole control for access to data or operations.
Common mistakes
- Pasting a live token into a public decoder: Even if the tool only decodes locally in the browser, its handling may not be clear. Use a local utility or an organization-approved tool for sensitive tokens, and revoke or replace exposed credentials according to your incident process.
- Trusting payload values before verification: An attacker can create a token-shaped string with arbitrary claims. Display decoded claims for diagnosis, never as evidence of identity.
- Validating only expiration: An unexpired token can still have the wrong issuer, audience, signature, subject, or permissions.
- Using a permissive library configuration: Defaults may not match your issuer or risk model. Review algorithm, issuer, audience, key, and clock-tolerance settings explicitly.
- Confusing authentication with authorization: A successfully authenticated service or user still needs permission for the requested resource and action.
- Ignoring the surrounding request: Headers, gateway transformations, API version differences, and environment configuration can cause failures even when the token itself is valid. Contract checks and request traces should be part of the investigation.
If the failure appears to be an infrastructure or deployment problem rather than an identity problem, pair token inspection with application health checks and deployment diagnostics. The cloud application health checks guide can help separate an authentication error from an unavailable or misconfigured service.
When to revisit
Revisit this JWT validation checklist whenever an identity provider, API gateway, authentication library, signing algorithm, key-discovery method, or authorization model changes. It is also useful before a seasonal planning or release cycle, when teams often review access boundaries and environment configuration together.
Make the review concrete: capture a non-sensitive example token shape, document expected issuer and audience values, list required claims for each protected API, and test expired, not-yet-valid, wrong-audience, invalid-signature, and insufficient-scope cases. Update the examples when your identity provider changes its claim conventions or your API changes its contract. If a token may have been exposed during debugging, stop using it and follow the organization's credential-replacement process rather than treating redaction as a complete remedy.
Before closing an incident, record whether the problem was decoding, signature verification, claim validation, authorization, request transport, or service health. That classification turns a one-time JWT debugging exercise into a reusable control for secure cloud-native application delivery.