I want to refresh the token when it expires, but the server returns 200 not 401 so the retry method will not execute.
Is there a way to manually call retry? Or some other solution?
You can customize Alamofire's .validate
closure to produce an error when certain responses have a 200 status code.
.validate { request, response, data in
guard response is token expiration else { return .success(()) }
return .failure(.responseValidationFailed(.customValidationFailed(error: <your error>)))
}
The error your produce here will be available to the retriers later in the pipeline so you can detect token expiration and issue the refresh.