-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There are some issues on the Network layer #18
Comments
This is a good point, I'll make use of this advice 😄
My reasoning for this was if we could validate the expiry of a token before making a request, we could prevent an additional network call for the failed request. Although this makes sense if a token may be invalidated for any other reason 😄 I'll apply this as well |
Created an |
survey-exam/data/src/main/java/com/example/nimblesurveys/data/api/auth/AuthInterceptor.kt Lines 12 to 14 in 9b8b6c1
survey-exam/data/src/main/java/com/example/nimblesurveys/data/api/auth/AuthInterceptor.kt Lines 28 to 30 in 9b8b6c1
survey-exam/data/src/main/java/com/example/nimblesurveys/data/repository/AuthRepositoryImpl.kt Lines 85 to 87 in 9b8b6c1
The Interceptor instance is injected into the Repository layer to just pass the access token, and the Interceptor now relies on the access token passed via
survey-exam/domain/src/main/java/com/example/nimblesurveys/domain/usecase/GetSurveysUseCase.kt Lines 21 to 28 in 9b8b6c1
|
OkHttp provides the Interceptors mechanism to process the same step on every request/response, therefore I would suggest making use of Interceptors to handle
Authorization
as the most common way instead of using@Header
on every request 😄With your implementation by validating the expiry time returned from the request, the application could receive unexpected authorization issue returns from the server-side, therefore, we should handle the refreshing mechanism on every 4xx error response rather than always validating expiry time on local 😄
survey-exam/data/src/main/java/com/example/nimblesurveys/data/repository/AuthRepositoryImpl.kt
Lines 45 to 54 in 3ae3ac7
The text was updated successfully, but these errors were encountered: