Android OkHttp, refresh expired token

后端 未结 5 1141
我寻月下人不归
我寻月下人不归 2021-01-30 18:14

Scenario: I am using OkHttp / Retrofit to access a web service: multiple HTTP requests are sent out at the same time. At some point the auth token expires, and

5条回答
  •  不思量自难忘°
    2021-01-30 19:10

    You should not use interceptors or implement the retry logic yourself as this leads to a maze of recursive issues.

    Instead implement the okhttp's Authenticator which is provided specifically to solve this problem:

    okHttpClient.setAuthenticator(...);
    

提交回复
热议问题