Authentication¶
restful supports two authentication strategies, configured per-API in the workspace config.
Bearer Token Auth¶
Automatic JWT lifecycle: login, cache, refresh, retry.
How it works:
- On first request, POST to
login_pathwith username/password - Extract token from response, parse JWT
expclaim - Cache to
.restful/cache.jsonkeyed by base URL - Inject
Authorization: Bearer <token>on every request - If token expires within 60s, auto-refresh before the next request
- On 401 response: invalidate token, re-authenticate, retry once
Password handling: The password_env field names an environment variable — passwords are never stored in config files.
API Key Auth¶
Static key injected as a header:
The value of the environment variable named by key_env is sent as the specified header on every request.
No Auth¶
Or omit the auth section entirely.
Token Cache¶
Cached tokens are stored in .restful/cache.json:
- Keyed by base URL — multiple APIs each get their own entry
- File permissions are 0600 (owner-only)
- Atomic writes using temp file + rename
- Never logged or printed