Skip to main content

Session refresh

Imported component documentation. Source: melodee-project/melodee-api at commit 0267c458207082337d9baf1130deeb65f43c9d4a. Version 1.0.1. License MIT. Status: implemented-and-automatically-verified candidate; not published, deployed or production-qualified. This is the component's committed documentation, not proof of a distribution release or production qualification.

Access credentials are valid for 15 minutes. Use POST /api/v1/auth/refresh before expiry, or immediately after a 401 caused by access expiry, to obtain a replacement. The request is unauthenticated at the HTTP middleware layer because the refresh credential is the authentication proof.

POST /api/v1/auth/refresh
Content-Type: application/json

{"refreshToken":"<current-or-expired-access-credential>"}

Successful response:

{"accessToken":"...","tokenType":"Bearer",
"expiresAtMillis":1790000000000,
"sessionExpiresAtMillis":1797000000000}

The previous credential is consumed. A second use returns 401 and revokes the session family. Browser clients also receive a replacement HttpOnly session cookie and CSRF cookie.

Client rules:

  • keep one refresh operation in flight (single-flight);
  • store the credential in OS-backed secure storage on mobile/desktop;
  • do not put credentials in URLs or logs;
  • on 401, refresh once, then retry the original request once;
  • after a replay error, discard the credential and re-authenticate;
  • bounded retry/backoff only; never loop refresh forever;
  • a 401 with a network-ambiguous outcome must be treated as possibly consumed: re-read secure storage, do not repeatedly replay the old value.

Automation credentials retain their separate 30-day explicit lifecycle and are not eligible for this endpoint. Device authorization remains its own flow.