https://kotlinlang.org logo
#ktor
Title
# ktor
g

gabin

03/06/2020, 12:02 PM
hey guys, is there some mechanism that allows to make refresh token request if I got a special error and repeat the initial request after that ?
r

ribesg

03/06/2020, 1:34 PM
Yes. Ktor Auth
Use a custom provider
You have 2 options I think
if it’s a JWT token or similar, you can read it and see if it’s still valid. If it’s not, refresh it in your implementation of
addRequestHeaders
before adding it
The other option is to have 2 providers, one which always adds the auth headers to requests, and the other which only exists to handle 401
g

gabin

03/06/2020, 1:41 PM
thx, I’ll take a look
12 Views