JWT Debugging Guide: Claims, Expiration, Signatures, and Safe Token Inspection
jwtauthenticationapi-securityoauthdebugging

JWT Debugging Guide: Claims, Expiration, Signatures, and Safe Token Inspection

CClicky Live Editorial Team
2026-11-30
7 min read

Decode JWTs safely, troubleshoot claims and expiration, and distinguish inspection from signature verification and token introspection.

A JWT decoder can reveal what a token contains, but decoding alone does not prove that the token is authentic or usable. This guide provides a repeatable workflow for inspecting headers and claims, troubleshooting expiration and audience errors, checking signatures safely, and deciding when a token or authentication configuration needs another review.

Overview

JSON Web Tokens (JWTs) are compact strings commonly used to carry claims between an identity provider, an application, and an API. A signed JWT usually has three Base64URL-encoded parts separated by periods:

header.payload.signature

The header describes the signing method and token type. The payload contains claims such as the subject, issuer, audience, and expiration time. The signature is used to detect whether the signed content has been altered and, depending on the algorithm and key arrangement, to establish that it was signed by a trusted party.

These parts are encoded, not encrypted. Anyone who obtains a JWT can generally decode its header and payload, so a token should not contain passwords, private keys, or other data that must remain secret. A token may still be confidential in practice because it can grant access while valid. Treat access and refresh tokens as sensitive bearer credentials.

The most important distinction in JWT debugging is the difference between three operations:

  • Decoding: parsing the header and payload without proving authenticity.
  • Validation: checking the signature, algorithm, time limits, issuer, audience, and other application rules.
  • Introspection: asking an authorization server whether a token is active and what permissions or metadata apply to it.

A free online JWT decoder or a local command-line utility is useful for inspecting a test token. It is not a substitute for server-side JWT signature verification or authorization checks.

What to track

1. Header fields

Start with the header, but do not accept its values as trusted until the signature has been verified. Common fields include:

FieldPurposeDebugging question
algIdentifies the signing algorithm.Does the verifier explicitly allow this algorithm?
typMay identify the token type, often JWT.Does the application expect this token format?
kidIdentifies a signing key when a key set contains several keys.Can the verifier resolve this key, and is it from the trusted issuer?

Algorithm errors often occur when the identity provider signs with one method while the API is configured for another. Avoid accepting whatever algorithm the token announces. Configure an explicit allowlist that matches the issuer and library configuration. For asymmetric signing, the issuer signs with a private key and the API verifies with a trusted public key. For symmetric signing, both sides use the same secret, which makes secret distribution and rotation especially important.

2. Payload claims

Claims are statements made by the token issuer. Their meaning depends on the protocol and application, but these are the fields most often involved in authentication failures:

ClaimTypical meaningWhat to check
issIssuer that created the token.Does it exactly match the configured trusted issuer?
subSubject represented by the token.Does the application map it to the expected user or service?
audIntended recipient or API.Does it contain the API's configured audience?
expExpiration time as a NumericDate.Is the current time before expiration, allowing for an intentional clock tolerance?
nbfNot-before time.Has the token become valid yet?
iatTime at which the token was issued.Was it issued during the expected login or refresh event?
jtiToken identifier, when present.Is it used for replay detection or revocation tracking?

JWT time claims are normally represented as seconds from the Unix epoch, not milliseconds. A value that is thirteen digits long may indicate that milliseconds were supplied where seconds were expected. Compare the decoded timestamp with the server's clock and timezone-independent epoch time rather than relying only on a browser display.

Also inspect application-specific claims such as scopes, roles, tenant identifiers, or permissions. A valid signature does not automatically grant every requested operation. Authorization should check the required permission for the specific route and resource.

3. Signature and key resolution

A signature check must cover the original encoded header and payload, not a reformatted or manually reconstructed version. The verifier should obtain keys through a trusted configuration or a trusted issuer metadata and key-set process. Do not blindly fetch a key from an untrusted URL included in a token header.

When signature verification fails, compare the issuer's published signing key, the token's kid, the configured algorithm, and the exact token string sent to the API. A copied token can be damaged by line breaks, surrounding quotation marks, or a missing segment. The HTTP authorization value should normally use the expected scheme and spacing, such as Authorization: Bearer <token>.

Cadence and checkpoints

JWT troubleshooting is easier when authentication assumptions are checked on a regular schedule instead of only during an outage. A monthly or quarterly review is reasonable for many teams; review sooner after an identity-provider change, key rotation, framework upgrade, domain change, or modification to token lifetimes.

At each review

  1. Use a newly generated test token rather than a copied production credential.
  2. Decode the token locally or with a tool that clearly explains whether data is transmitted or stored.
  3. Record the expected issuer, audience, algorithm, key identifier, and time-claim behavior.
  4. Send the token to a non-production endpoint and confirm that valid requests succeed.
  5. Test an expired token, a wrong-audience token, a wrong-issuer token, and a modified payload.
  6. Confirm that each negative case is rejected and produces a useful server-side diagnostic without exposing the token in logs.

Keep a small authentication test matrix in version control. Include the identity provider, API audience, accepted algorithms, key discovery configuration, clock-skew tolerance, access-token lifetime, refresh behavior, and expected error category. This turns a one-time JWT inspection into a repeatable developer tool workflow.

When an application uses OpenID Connect, distinguish the identity token from an access token. An identity token describes an authentication event for the client application; an access token is intended for a resource server. Passing the wrong token to an API can look like an expiration or signature problem even when the token itself is well formed.

How to interpret changes

Use the failure pattern to narrow the investigation:

  • Malformed token: Check for missing periods, damaged Base64URL content, accidental quotes, or a truncated authorization header.
  • Expired token: Compare exp with the API server's clock. Investigate refresh handling and clock synchronization before simply extending token lifetime.
  • Not yet valid: Inspect nbf and clock differences between the issuer, client, and API.
  • Invalid audience: Confirm that the client requested a token for the API's audience and that the API's expected value matches the issuer configuration.
  • Invalid issuer: Check the exact issuer URL, including scheme, host, path, and trailing-slash conventions where relevant.
  • Signature failure: Compare the selected key, kid, algorithm, secret or public key, and the unmodified token string.
  • Valid token but forbidden request: Move from authentication to authorization. Inspect scopes, roles, tenant context, and resource ownership.

Browser behavior can add another layer of confusion. Inspect the network request to see whether the token is actually sent, whether a cookie is included under the current cookie rules, and whether a cross-origin request is blocked before the API receives it. Browser storage can also reveal whether an application is reading an old token after login. For a broader storage review, see the Browser Storage Debugging Guide.

Do not fix an authentication error by disabling signature checks, accepting every algorithm, ignoring the audience, or adding a large clock tolerance without understanding the consequence. These changes can hide configuration defects and weaken the boundary between an issuer and an API.

If you are comparing token strings, API responses, or configuration files, a structured diff is often more useful than visual inspection. The Text Diff Workflow can help isolate changes while keeping secrets out of shared tools.

When to revisit

Revisit this JWT debugging checklist monthly or quarterly, and immediately after any authentication-related change. The highest-value update points are:

  • Identity-provider migration or tenant configuration change.
  • Signing-key rotation, key-set URL change, or change to kid handling.
  • API gateway, authentication library, or framework upgrade.
  • Changes to access-token, refresh-token, or session lifetimes.
  • New audiences, issuers, scopes, roles, or resource servers.
  • Reports of intermittent login failures, unexpected 401 responses, or unexplained 403 responses.
  • Changes to browser storage, cookie settings, reverse proxies, or cross-origin request configuration.

Before using a decode JWT token online tool, remove real credentials from the workflow and generate a disposable test token. Never paste a production access token, refresh token, session cookie, private key, or client secret into a public decoder. If a sensitive token has been exposed, treat it as compromised and follow the relevant revocation or rotation procedure.

For related data-handling practices, read Safe Data Transformation for Web Developers. Then run the following short checkpoint: decode only test data, verify issuer and audience, check time claims in seconds, validate the signature with a trusted key, test authorization separately, and record the result in your authentication test matrix. That sequence keeps a JWT decoder in its proper role: a useful inspection aid, not evidence that a token is trustworthy.

Related Topics

#jwt#authentication#api-security#oauth#debugging
C

Clicky Live Editorial Team

Developer Tools Editor

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.