Hello everyone, I have a project on a clean architect and I have the task of logging out and sending to the login screen in case 401 comes in response to a request.

The release is released by a separate UseCase, which must be called from the interaction.

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

Maybe someone has an idea how to make no crutch decision?

    1 answer 1

    Do you really need to send a request signed by an obsolete token after the user received error 401? 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 necessary request using an object from an unauthorized zone and send the user to the login screen (locally). Under the link you can see the details: https://github.com/AndroidArchitecture/AndroidArchitectureBook/blob/master/cases/auth/Auth_article.md

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