Hi all. Is there a way to configure `ktor-client` ...
# ktor
x
Hi all. Is there a way to configure
ktor-client
to not reuse
loadTokens
/
defaultRequest
for subsequent requests, i.e a way to always invoke
defaultRequest
every time a request is made? Use-case in 🧵
I load my tokens from disk
Copy code
Auth {
  bearer {
    loadTokens {
      val credentials: DeviceCredentials = store.get() 
      BearerTokens(
        accessToken = credentials.access_token.encoded,
        refreshToken = credentials.refresh_token.encoded
      )
    }
  }
}
but stored token can change overtime, and when it does, my ktor client is still using the old token
a
So you want the
loadTokens
block to be called each time a request is made?
x
Yes, same behaviour for
defaultRequest
Not sure if this is doable 🫠
a
Unfortunately, it’s not configurable that way. You can try to detect when the file is changed and call the clearToken method to remove the cache.