- All Courses
- API Design with Node.js
- Auth and Safety
- Authentication with tokens
Authentication with tokens
A signed token lets you verify the caller without a database lookup per request.
Overview
Establishing who is calling
A signed token lets you verify the caller without a database lookup per request. Verify the signature, the issuer, the audience, and the expiry — skipping any of those turns the token into a decorative header.
Short-lived access tokens with a refresh mechanism limit the damage from a leaked token. A token valid for a year is a password with worse handling.
Storage on the client is the weak point. A token in local storage is readable by any script that gets injected; an http-only cookie is not, at the cost of needing cross-site request protection.
In this lesson you will:
- Verify a token on every request
- Keep access tokens short-lived
- Store credentials safely on the client
Resources
Notes are not saved yet — they clear when you leave this page.
Pagination, filtering, and sorting
3m
Authorisation and scopes
8m