A Bearer Token is a type of access token used for authentication and authorization in web applications and APIs. The term "Bearer" means "holder," which implies that anyone in possession of the token can access protected resources—without additional verification.
Characteristics of a Bearer Token:
- Self-contained: It includes all necessary authentication information.
- No additional identity check: Whoever holds the token can use it.
- Sent in HTTP headers: Typically as
Authorization: Bearer <token>
.
- Often time-limited: Tokens have expiration times to reduce misuse.
- Commonly used with OAuth 2.0: For example, when authenticating with third-party services.
Example of an HTTP request with a Bearer Token:
GET /protected-data HTTP/1.1
Host: api.example.com
Authorization: Bearer abcdef123456
Risks:
- No protection if stolen: If someone intercepts the token, they can impersonate the user.
- Must be securely stored: Should not be exposed in client-side code or URLs.
💡 Tip: To enhance security, use short-lived tokens and transmit them only over HTTPS.