A protected API route usually requires a client to prove its identity before returning data or accepting a change. Many APIs carry that proof in a JSON Web Token (JWT) sent as a Bearer token. A careful test checks more than whether one token works: it also checks what happens when the token is missing, expired, malformed, or valid but lacks permission.
Test a Bearer token with API TesterWhat is a JWT and what is inside it?
A JSON Web Token is a compact way to represent claims between parties. A common signed JWT in compact JWS form has three Base64URL-encoded segments: a header, a payload, and a signature, separated by periods. The header often identifies a signing algorithm and key ID; the payload may contain claims such as subject (sub), issuer (iss), audience (aud), and expiration (exp).
header.payload.signature
// Example decoded shape; values are illustrative, not a real token.
{
"alg": "RS256",
"kid": "key-2026-01"
}
{
"iss": "https://identity.example.test",
"sub": "user-42",
"aud": "notes-api",
"exp": 1793520000
}Base64URL encoding is not encryption. Anyone who has a typical signed JWT can decode its header and payload, so do not put passwords, API secrets, or private personal data in claims. Encrypted JWT formats exist, but a three-segment token commonly used by an API is often signed, not encrypted. A signature can help a server detect changes; a client must not accept claims just because they decode into readable JSON.
Send a JWT to a protected REST API
An identity or authorization service issues an access token after the client completes the application’s authentication flow. To test a protected resource, copy a development access token and send it in the HTTP Authorization header using the Bearer scheme. Do not send a password or a refresh token to the resource endpoint.
curl -i https://api.example.test/v1/profile \
-H "Accept: application/json" \
-H "Authorization: Bearer YOUR_TEST_ACCESS_TOKEN"In JsonifyTools API Tester, enter the protected endpoint, open the Auth controls, choose Bearer Token or JWT, and paste a development token. Send the request and inspect the status, response headers, and body. Use a short-lived token scoped for a test account; treat it as a credential while it is valid.
- Step 1
No token
Confirm the endpoint rejects an unauthenticated request.
- Step 2
Valid token
Check the expected response for the correct test identity.
- Step 3
Expired token
Confirm expiration is enforced by the API.
- Step 4
Least privilege
Verify a valid identity cannot exceed its permissions.
Test missing, invalid, and expired JWTs
Start with a request that has no Authorization header. Then try an obviously malformed token in a local or staging environment and an expired token issued for a test account. A protected route should reject them without exposing protected data. Next, use a valid token for the wrong test identity or with insufficient scope, if your test setup allows that case. Use controlled fixtures; never alter a real user’s token or attempt to access another person’s data.
# Missing credential
curl -i https://api.example.test/v1/profile
# Malformed placeholder (expected to be rejected)
curl -i https://api.example.test/v1/profile \
-H "Authorization: Bearer not-a-jwt"
# Expired test token: issue one through your local test identity service,
# then repeat the request after its exp time.Also test a token with an unexpected issuer or audience when your test issuer can provide one. A resource server should validate the signature using trusted keys and enforce the claims required by its contract. Simply receiving a well-formed three-part string is not authentication.
Understand 401 versus 403 during JWT testing
A 401 Unauthorized response generally means the request lacks acceptable authentication credentials. That can mean the token is missing, invalid, expired, or otherwise not accepted. A 403 Forbidden generally means the request is understood but the authenticated caller is not allowed to perform the action. APIs can choose a 404 when they do not want to reveal whether a protected resource exists, so check the service contract and error body instead of relying on a status alone.
Make a small test matrix: one unauthenticated request, one authorized request, and one authenticated request with a known permission boundary. Record the expected status and confirm no sensitive response data appears in rejected cases. The purpose is to verify your own API’s policy, not to probe a third-party service.
JWT security mistakes to check
Trusting decoded claims
Decoding displays values; it does not verify a signature. The API must validate cryptography and trusted key selection.
Accepting an unintended algorithm
Use a server-side allowlist and follow current JWT best practices. Do not let an untrusted token header choose arbitrary verification behavior.
Skipping issuer or audience checks
A token signed by a trusted issuer can still be intended for a different service. Check the claims required by your API.
Keeping tokens too long or exposing them
Use appropriate lifetimes and storage. Avoid tokens in URLs, source control, screenshots, logs, and shared cURL commands.
The JWT specification (RFC 7519) defines JWT claims and representations; JWT Best Current Practices (RFC 8725) describes implementation pitfalls and validation requirements. Use your framework’s maintained JWT library instead of writing signature validation by hand.
Access tokens and refresh tokens are not interchangeable
An access token is presented to a resource API to access a protected operation. A refresh token is presented to the authorization service’s token endpoint to request a replacement access token, subject to the client and grant rules. Refresh tokens need stronger protection because they can extend a session. A JWT is one possible token format; OAuth access tokens can also be opaque strings.
Use the JsonifyTools JWT Decoder to inspect visible claims such as expiration while debugging a development token, and use API Tester to see how your endpoint handles it. Do not paste production credentials into an online tool, include private tokens in a blog, or share a cURL command before removing secrets.
Continue your workflow
Related developer tools
Use these tools to build a request, inspect its data, and understand authentication responses.