2
我有一個場景,我添加一個攔截器,其中包含一個Authorization
String
在標題中從API獲取token
。當我取回一個令牌時,我希望添加一個新的攔截器,它將接收到的令牌添加到所有後續請求的頭部。添加和刪除攔截器
如何刪除之前包含Authorization
令牌的攔截器,因爲它不再需要?
private void removeAuthorizationInterceptor()
{
for (Interceptor interceptor : App.getOkHttpClient().newBuilder().networkInterceptors())
{
// Find the interceptor which has the Authorization token and remove it
}
}