android – How to arrange di to call usecase from Interceptor


Hello everyone, I have a project on a clean architect and the task of logging out of use and popping out to the login screen appears if a 401 is received in response to a request.

Logging out is released in a separate UseCase, which must be called from the interactor.

Because of this, a circular dependency problem appears: Interceptor -> UseCase -> Repository -> Retrofit -> Okhttp -> Interceptor.

Maybe someone has thoughts on how to make a non-crutch decision?


Do you really need to send a request signed with an obsolete token after the user receives a 401 error? This moment seems strange to me.

One of the standard approaches is that you use different objects to access authorized and unauthorized zones. In this case, you can make the required request using the unauthorized zone object and send the user to the login screen (locally). You can check the details here:

The case in which a stale token needs to be updated without user interaction is also described in the example.

Scroll to Top