-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Auth Header Bearer Token refresh, AF5 beta #61
Comments
Hi @n13 Thanks a ton for reporting this ! |
Happy to provide a PR for you that supports the already existing RequestAdapter- I am using this now for this purpose and thinking apart from edge cases, it's good enough for me. Firebase auth has a listener to token changes so once I have a valid token, I can rely on the listener to update when necessary. Which leaves the edge cases of app start and awake from sleep which I am dealing with. RequestAdapter support is a very small change. Thanks for making ws, I love it. |
Before each call, I need to check if my bearer token is still OK, and if not get a new one, and then set it in the headers.
I looked into the code, it will be trivial to add a RequestAdapter to ws - as supported by Alamofire 4 - and that could do that except not asynchronously. So I'd still get occasional errors when the token isn't refreshed in time. And I'd have to deal with those errors on a code level which kind of destroys the elegance and simplicity of using ws.
AlamoFire 5 has a built in solution for this exact problem.
I have two questions
Has anybody looked into upgrading to AlamoFire 5 (currently in beta)? That would allow for asynchronous bearer token refresh, making what I need trivial to implement. They added a callback to RequestAdapter - super easy to use.
Is there another good way you can think of to provide a feature similar to AF5 callback based RequestAdapter? Didn't really see one...
As ws library is concerned upgrading to AF5 is probably the best way to go about it.
The text was updated successfully, but these errors were encountered: