Hi, with ktor client, is there a equivalent of okh...
# ktor
u
Hi, with ktor client, is there a equivalent of okhttp interceptors or authenticator?
👀 1
r
As server part its features you add to the client. See: https://ktor.io/docs/features-auth.html#providers
u
I mean okhttp has Authenticator feature which callbacks get called when you receive a 401 so you can refresh token, provide basic auth too but mostly to globally refresh the token. Now with ktor it seems I need to check for this manually on every callsite Interceptors detto
l
@ursus Your use case is OAuth2, right?
u
well sort of, just access+refresh token pattern
l
I didn't try this yet (made a half-broken homegrown one that I plan to revisit or replace), but here's an article that guides you using an open source library that has a ktor feature for that: https://medium.com/l-r-engineering/oauth2-in-android-authorization-code-flow-ffc4355dd473
The author of the article @Alex Queudot is not in this channel 🤔
u
thx!
a
Hi! 👋 So many channels I didn’t spot this one 🙂 You can use this feature from @Kurt Renzo Acosta which works perfectly for intercepting unauthorized responses https://github.com/kuuuurt/ktor-client-oauth-feature
k
I haven’t been updating that library though. Feel free to file an issue if it doesn’t suit your use case and I’ll see what I can do!