Hi, with ktor client, is there a equivalent of okh...
# ktor
Hi, with ktor client, is there a equivalent of okhttp interceptors or authenticator?
👀 1
As server part its features you add to the client. See: https://ktor.io/docs/features-auth.html#providers
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
@ursus Your use case is OAuth2, right?
well sort of, just access+refresh token pattern
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 🤔
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
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!