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
Jwt authentication tokens refresh logic inside ApolloInterceptor #2461
Comments
@Sserra90 using an |
Closing due to inactivity. @Sserra90 , let me know if you want it to be reopened |
Good Job! I think you have to put refresh token logic's in onFailure() fun since if the API call returns with status code 401 (unauthorized) there is an exception that will be thrown and onResponse() will not continue then call onFailure() will be called, you depend always on the API call will return with code 200, and in some cases, that does not happen. so because of the exception which thrown, you have to handle onFailure() in case status code 401. It would be like this
|
Question.
Automatically refresh JWT tokens using ApolloInterceptor.
Hy guys i'm working on an application the needs to refresh authentication tokens under the hood when it receives a Unauthenticated error from GraphQL. I implemented this before for normal API using OkHttp interceptors and i ported some of the logic to ApolloInterceptor.
I tried to look at internal Apollo interceptors source code to see how they work and i managed to make a working solution. However because it's my first time using the apollo-android library i would like to ask for some feedback maybe i'm overlooking something.
These are the pre-requisites that i took into account.
Is this the correct way or doing this kind of operation or is there any alternative ?
Thanks
The text was updated successfully, but these errors were encountered: