Hello, I'm using Auth plugin for bearer tokens (cl...
# ktor
k
Hello, I'm using Auth plugin for bearer tokens (client side). Correct me if I'm wrong - as I understand tokens are loaded during call and cached, then refreshed only, when 401 status occurs. In my case I have to manually refresh token after some user action before perform network call (backend api design decision). How to achieve it?
I solved it by calling in right moment:
Copy code
private fun HttpClient.resetTokens() {
    pluginOrNull(Auth)?.providers?.forEach { provider ->
        if (provider is BearerAuthProvider) {
            provider.clearToken()
        }
    }
}
👍 1