Tamara Bernad Tamara Bernad - 10 months ago 198
Swift Question

Alamofire 4.0 RequestRetrier should(_,retry,with,completion) not being called

I am using the

of Alamofire 4.0 to control the retrying of requests for expired access token. I am following the documentation here.

I have a very similar implementation to the example available in the documentation
which implements

The issue I am encountering is that
func should(_ manager: SessionManager, retry request: Request, with error: Error, completion: @escaping RequestRetryCompletion)
is never being called. The
method of the
implementation does get called though.

Debugging, I see that
only calls
when there is an error, but requests that return status codes related to Authorization issues, don't seem to generate errors, so that method never gets called.

Am I missing something here?

Answer Source

Maybe you are not getting an error. 400 responses aren't considered as error by Alamofire. In case you want get an error when receiving a 400 code you should chain validate() to the request. If this is your case you can find more information here.