KDefaultTokenRefresher

constructor(refreshUrl: String, getRefreshToken: suspend () -> String?, onTokenRefreshed: suspend (accessToken: String, refreshToken: String) -> Unit, onFailed: suspend () -> Unit, authProvider: KAuthProvider? = null)(source)

Parameters

refreshUrl

Full URL of the refresh endpoint. Can differ from KHttpConfig.baseUrl (e.g. a dedicated auth server).

getRefreshToken

Returns the current refresh token.

onTokenRefreshed

Called with (accessToken, refreshToken) on success. Persist the new tokens here.

onFailed

Called when the refresh request fails or returns non-200. Clear the session here.

authProvider

The same KAuthProvider passed to KHttpConfig.authProvider. Used to re-apply the auth header on the retried request after a successful refresh — works with any auth scheme.