我正在使用Alamofire 4.0的RequestRetrier
來控制對過期訪問令牌的請求的重試。我正在關注文檔here。Alamofire 4.0 RequestRetrier應該(_,retry,with,completion)不被調用
我和文檔OAuth2Handler
中可用的示例非常類似,它們實現了RequestAdapter
和RequestRetrier
。
我遇到的問題是func should(_ manager: SessionManager, retry request: Request, with error: Error, completion: @escaping RequestRetryCompletion)
永遠不會被調用。 RequestAdapter
實現的adapt
方法確實被調用。
調試,我看到SessionDelegate
僅調用should(_,retry,with,completion)
時出現錯誤,但返回與授權問題狀態代碼的請求,似乎沒有產生錯誤,所以該方法不會被調用。
我失去了一些東西在這裏?
忘了調用驗證!就是這樣,感謝@crisisGriega! –