Ciao Guys! Today I tried the Ktor 3.0.0-beta-1 to ...
# ktor
c
Ciao Guys! Today I tried the Ktor 3.0.0-beta-1 to check wether there are breaking changes affecting my app. I found out that the following line of code doesn't compile anymore.
Copy code
client.plugin(Auth).providers.filterIsInstance<BearerAuthProvider>().first().clearToken()
where client is an instance of HttpClient. The property providers doesn't exist anymore. The code above clears the token holder instance inside the BearerAuthProvider. I'm running this line of code when the user is logging out. I'm using Ktor 2.3.7 What would be the equivalent code in Ktor 3.0.0? Thanks
p
I think it should be like this:
Copy code
import io.ktor.client.plugins.auth.authProviders

client.authProviders.filterIsInstance<BearerAuthProvider>().first().clearToken()
Haven't tried it myself, but at least it would compile.
c
Great suggestion @p-schneider! Thanks!
a
Or even more succinct:
Copy code
client.authProvider<BearerAuthProvider>()?.clearToken()
K 2
thank you color 2