What is jwt bearer token
Last updated: April 1, 2026
Key Facts
- Bearer tokens are passed in the HTTP Authorization header using the format 'Bearer {jwt-token}' for stateless authentication
- JWT bearer tokens are stateless, eliminating the need for server-side session storage or database lookups on every request
- The server validates the token's cryptographic signature without connecting to external systems, enabling fast, scalable authentication
- Bearer tokens are typically short-lived (minutes to hours) and may be refreshed using a separate refresh token mechanism
- Bearer tokens must be transmitted exclusively over HTTPS to prevent token interception and unauthorized access
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
- Stateless: No server-side session storage required, simplifying horizontal scaling
- Scalable: Multiple servers can validate the same token independently using the same secret key
- Mobile-Friendly: Ideal for mobile apps and SPAs that need to persist authentication across app restarts
- Cross-Domain: Supports authentication across different domains and microservices easily
- Reduced Database Load: No session lookup queries needed for every authenticated request
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.
More What Is in Daily Life
Also in Daily Life
More "What Is" Questions
Trending on WhatAnswers
Browse by Topic
Browse by Question Type
Sources
- RFC 6750 - OAuth 2.0 Bearer Token UsagePublic Domain
- Wikipedia - JSON Web TokenCC-BY-SA-4.0