https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

Adil

03/27/2024, 11:08 AM
(FIXED)Has any one worked with ktor before? i am having some trouble with token part. i.e is the loadTokens called on every request?.
install(Auth) {
bearer {
loadTokens {
m

mohamed rejeb

03/27/2024, 11:37 AM
I remember having problems with loadTokens, example when the user logout ktor keeps setting the old token. It's better to add a default request and set the token manually there to avoid this issue.
👀 1
a

Alexander Zhirkevich

03/27/2024, 12:27 PM
To clear bearer tokens after logout you need to call
Copy code
httpClient.authProvider<BearerAuthProvider>()?.clearToken()
🙌 1
m

mohamed rejeb

03/27/2024, 12:36 PM
Nice, so by calling clearToken, loadTokens is going to be called in the next request right?
a

Alexander Zhirkevich

03/27/2024, 12:38 PM
Yes, if authorization is required for the next request or if
sendWithoutRequest
is configured
👀 1
thank you color 1
j

jw

03/27/2024, 12:46 PM
Note that there's #ktor for the library specifically
a

Adil

03/27/2024, 10:14 PM
Thanks all i ll try some of things and see if that works 🙂
@mohamed rejeb the logout part is exact issue i am facing..