Authenticator不会从服务器回拨401。但是,当我关闭应用程序并重新启动时,它会提供回调。为什么会这样?
@Provides
@Singleton
internal fun provideOkHttpClient(): OkHttpClient {
interceptor.level = HttpLoggingInterceptor.Level.BODY
val client = OkHttpClient.Builder()
.authenticator(Authenticator(MainApplication.instance!!))
.addInterceptor(authorizationInterceptor)
.addInterceptor(interceptor)
.addInterceptor(cacheInterceptor)
.cache(myCache)
.addNetworkInterceptor(stethoInterceptor)
.retryOnConnectionFailure(true)
.connectTimeout(30, TimeUnit.MINUTES)
.readTimeout(30, TimeUnit.MINUTES)
.writeTimeout(30, TimeUnit.MINUTES)
return client.build()
}