
Bearer Tokens and Refresh Flows in Go APIs Explained
Build short-lived JWT access tokens and rotating refresh tokens in Go: pinned verification, hashed storage, reuse detection and a concurrent refresh trap.
Tag
6 articles

Build short-lived JWT access tokens and rotating refresh tokens in Go: pinned verification, hashed storage, reuse detection and a concurrent refresh trap.

Meter API usage and enforce quotas in Go: an atomic conditional UPDATE, idempotent events, weighted routes, refunds for 5xx, UTC periods and reconciliation.

Generate, store and rotate API keys in Go: a prefixed format with a checksum, SHA-256 storage, throttled last-used, overlap rotation and 85 ns rejection.

Rate limit a Go API per key and per route with token buckets: weighted costs, 429 with Retry-After, idle sweeping, a fake test clock and 123 ns decisions.

Build Go API authentication with one Principal and three mechanisms: hashed API keys, signed bearer tokens and cookie sessions, with 401 versus 403 and CSRF.

Build a small OAuth 2 server in Go: client credentials, authorization code with PKCE, exact redirect matching, single-use codes and a scope-checking API.