Bearer tokens — Middleware · Hono

Protect the API with tokens in the Authorization header: one token that may read, one that may also write, and the three different refusals a client can get.

What you will learn

Read the theory for Bearer tokens

All Middleware lessons

All Hono courses

loading types…

What you'll learn

  • Guard routes with bearerAuth({ token }) and tell its three refusals apart: no header, a malformed header, a wrong token
  • Accept several tokens with an array, and give reads and writes different guards with app.on()
  • Know where a fixed token stops and a verified one begins: verifyToken, and the next lesson's JWT