clearToken

open override fun clearToken()(source)

Clears the currently stored authentication tokens from the cache.

This method should be called in the following cases:

  • When access or refresh tokens have been updated externally

  • When you want to clear sensitive token data (for example, during logout)

Note: The result of loadTokens invocation is cached internally by default. Calling this method will force the next authentication attempt to fetch fresh tokens through the configured loadTokens function.

If BearerAuthConfig.cacheTokens is set to false, this method has no effect as tokens are not cached.

Example usage:

// Clear tokens on logout
client.authProvider<BearerAuthProvider>()?.clearToken()
// Or use the convenience extension
client.clearAuthTokens()

Report a problem