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.
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.