OkHTTP身份验证器未在HTTP 401上调用

时间:2019-03-05 07:30:07

标签: kotlin okhttp authenticator

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()
}

0 个答案:

没有答案