pub fn spawn_token_refresh_task(
expires_in: u64,
refresh_token: String,
cmd_tx: UnboundedSender<HandlerCommand>,
cancel_token: CancellationToken,
)Expand description
Spawns a background task to refresh the authentication token before it expires.
The task sleeps until 80% of the token lifetime has passed, then sends a refresh request.
When the refresh succeeds, a new Authenticated message will be received, which triggers
another refresh task - creating a continuous refresh cycle.
The cancel_token allows the caller to cancel a stale refresh task when a new
authentication cycle begins (e.g., after reconnection re-auth).