Does ktor client provide any mechanism to re-reque...
# multiplatform
f
Does ktor client provide any mechanism to re-request the same request with new refresh_token which thrown error_code 401? This is what we do in Retrofit with okHttpClient.
Copy code
override fun authenticate(route: Route?, response: Response): Request? {
    /*
    * 1. Check for migration
    * 2. Fetch new auth and refresh token
    * 3. Update header of current request and return
    * 4. Save new token in storage
    * */

    val updatedToken = fetchNewToken() ?: return null

    return newRequest( 
              // failed-request
              response.request, 
              updatedToken
           )
}
m
Yes, you can use the Auth plugin: https://ktor.io/docs/auth.html