client
client copied to clipboard
Interceptor to renew token
Here is what I have put in place with java retrofit library and I wanted to know if it's possible (or will be) to do it with this one also.
So I had an Interceptor who was executing the request, once I was getting a 401 I was doing stuff to renew the token and retry the request with the new token. It's very cool way to deal with token renewal easily :) I would like to put that in place again in dart but I don't see how it can be possible.
Here is where the magic append in retrofit https://github.com/square/okhttp/blob/5b37cda9e00626f43acf354df145fd452c3031f1/okhttp/src/main/java/okhttp3/internal/http/RealInterceptorChain.java#L124
Basically there no intercept before/after, just one method intercept with a Chain
object and this object can proceed
the request to get a response. The request is processed once by the last interceptors (by recursivity) and then pass back to all interceptors in order.
Would you be interested to make such changes @Jaguar-dart/authors ? For renew the token inside the interceptors that's the only way I see.