Android. Automatic accessToken update with displaying the response data from the updated request on the screen

29 views Asked by At

I need a method that will refresh the accessToken using the refreshToken if the server returns an error indicating that the accessToken has expired. It should send a new request (a copy of the old one) but with the updated accessToken. Additionally, it should allow retrieving data from the response of this request, for example, to display it on the screen.

The implementation of the Authenticator from OkHttp does not allow achieving the last condition because the data of the second request with the updated token only comes to the authenticate method of this Authenticator itself. However, I need them to first go to the repository, then to the ViewModel, and be displayed on the screen.

I use Kotlin with MVVM and Clean Architecture.

0

There are 0 answers