Skip to content

Auth Header Bearer Token refresh, AF5 beta #61

@n13

Description

@n13

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions