← all projects

argent-http-core

A production Ktor HttpClient factory built around token refresh: refresh-on-401 with careful failure classification, optional-bearer auth, and a pure unit-tested refresh policy.

View on GitHub ↗Kotlinupdated today

KotlinKtorAuth

High-level design

Three client builders over one shared base config, with the refresh policy extracted as a pure function.

authenticated client

bearer token + refresh-on-401 with retry and exponential backoff

optional-bearer client

token attached only when present, read fresh each request — for pre/post-login endpoints

decideRefresh

pure status→decision mapping: 401/403 expire the session, 5xx/network keep it

Low-level design

9 unit tests over the refresh policy; JVM module, Apache-2.0, CI.

  • A 5xx on refresh keeps the user logged in — logging out on a backend blip would turn a transient outage into a support-ticket storm
  • Tokens are read fresh from a TokenStore on every request and refresh, so a logout is reflected immediately with no memoised-token cache to invalidate