What is jwt bearer token

Last updated: April 1, 2026

Quick Answer: A JWT bearer token is a security credential containing an encoded JSON Web Token transmitted in HTTP Authorization headers to authenticate API requests and verify user identity.

Key Facts

Overview

A JWT bearer token is a method of transmitting JSON Web Tokens as authorization credentials in HTTP requests. The term 'bearer' indicates that whoever bears (possesses) the token is authorized to access the protected resource, without proving identity through other means. This mechanism is widely used in modern web APIs and mobile applications for stateless authentication and authorization.

How Bearer Tokens Work

When a user logs in, the server generates a JWT containing claims about the user (user ID, roles, permissions) and signs it with a secret key. The client receives this JWT and includes it in subsequent API requests using the Authorization header: Authorization: Bearer eyJhbGciOiJIUzI1NiIs.... The server receives the request, extracts the token, verifies its signature, checks expiration, and grants access if valid—all without querying a database.

Advantages Over Session-Based Authentication

Token Lifetime and Refresh

Bearer tokens are typically configured with a short expiration time (15 minutes to 1 hour) to limit the window of exposure if a token is compromised. When a token expires, the client requests a new one using a refresh token—a longer-lived credential that can generate new access tokens without requiring the user to log in again. This two-token approach balances security (short-lived access tokens) with user experience (no frequent re-authentication).

Security Best Practices

Bearer tokens must only be transmitted over HTTPS to prevent interception by attackers. They should not be stored in insecure locations like localStorage (susceptible to XSS) but rather in secure, HTTP-only cookies when possible. Tokens should include minimal sensitive information and should be validated on every request. Additionally, servers should implement token revocation mechanisms (blacklists or token refresh endpoints) to invalidate tokens if compromise is suspected.

Related Questions

What is the difference between JWT bearer tokens and API keys?

Bearer tokens are time-limited, user-specific credentials containing claims and verified by cryptographic signatures, while API keys are static long-lived credentials used for service-to-service authentication. Tokens are more secure for user authentication; API keys are better for non-expiring service credentials.

How do you refresh an expired JWT bearer token?

When a JWT bearer token expires, the client sends the refresh token to a dedicated refresh endpoint, which validates it and returns a new access token. This allows users to remain authenticated without re-entering credentials.

Where should JWT bearer tokens be stored in web applications?

JWT bearer tokens should be stored in secure, HTTP-only cookies that prevent JavaScript access, protecting against XSS attacks. If cookies cannot be used, store them in memory, but be aware this loses token persistence across page reloads.

Sources

  1. RFC 6750 - OAuth 2.0 Bearer Token Usage Public Domain
  2. Wikipedia - JSON Web Token CC-BY-SA-4.0