由于我需要将add header初始化为全局,以便在所有API调用中获取头,我尝试过,但在调试时,它不会在API调用中发送头。
val client = OkHttpClient.Builder()
.authenticator { _, response ->
response.request().newBuilder().addHeader(
"authorization","123").build()
}
.connectTimeout(60, TimeUnit.SECONDS)
.readTimeout(60, TimeUnit.SECONDS)
.writeTimeout(60, TimeUnit.SECONDS)
.build()
AndroidNetworking.initialize(applicationContext, client)
1条答案
按热度按时间2lpgd9681#
你能用下面提到的代码替换你的代码并重试吗