Loading Depth Study
Preparing your workspace
Token-based authentication allows a client to present a signed credential that the server can validate to identify the requester.
A JSON Web Token, or JWT, contains encoded claims and a cryptographic signature. A server can verify the signature and inspect selected claims such as subject or expiration. JWTs can be useful in APIs, but they should not be treated as a universal replacement for sessions. Sensitive data should not be placed into token payloads merely because the payload is encoded. Token expiration, rotation, storage, revocation strategy, and audience or issuer validation should be designed carefully.
A mobile or web client may send an access token with an API request to access authenticated resources.
Authorization: Bearer eyJhbGciOiJIUzI1NiIs... // Server verifies signature and claims const payload = verifyToken(token);
The server validates the bearer token before allowing access to a protected API.