Handling authentication token refreshing with fetch interceptor #3051
Closed
jezzsantos
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Using the fetch client, we are adding an error interceptor to catch the cases when a 401 is returned for using any of our generated APIs.
I have some questions on the design.
In the error interceptor we are looking at the
response.statusand if 401, we are calling ourrefreshToken()generated client method.After this returns, we are retrying the original request by using fetch directly (configured with original request details) to make the original request, and to avoid using the generated fetch client.
If this request succeeds, we resolve the response to the interceptor.
If this request fails, we also resolve the failed response error to the interceptor.
I have a few questions, about how this should correctly behave with respect to being called by the generated fetch client:
What is the correct behavior here for such an error interceptor?
Beta Was this translation helpful? Give feedback.
All reactions