In my application the network implementation (particularly a HTTP request interceptor) requires an authorization token stored in local persistent storage.
Now, following clean architecture, both network implementation and persistent storage are in the outer most, the framework layer.
The access token can be retrieved via a repository (where the implementation is in the gateway/interface adapters layer and the repository interface is in the inner-most/entity layer.
How should the control flow be in my scenario? Should it go
- via a use case, since, in the ring diagram, the use case layer entirely encapsulates the entity layer
- via the repository interface and skip the use case layer?
As counter arguments of 1
I see that
- I require a "get access token" use case, which is not a real use case from the user perspective.
- If the use case layer always encapsulates the entity layer, is it ok that the repository interface is in the entity layer but the implementation only in the interface adapters layer (skipping the use case layer)?
As counter argument of 2
I see that the use case layer is only between entities and user facing interfaces (controllers, presenters) but not between entities and data gateways - meaning the use cases layer does not actually fully encapsulate the entity layer, which would mean the ring representation of the layers is not accurate.