I have a scenario where I add an interceptor containing an Authorization
String
in the header to get back a token
from the API. When I get back a token, I wish to add a new interceptor which will add the received token to the header of all subsequent requests.
How do I remove the previous Interceptor which contains the Authorization
token since it's no longer needed?
private void removeAuthorizationInterceptor()
{
for (Interceptor interceptor : App.getOkHttpClient().newBuilder().networkInterceptors())
{
// Find the interceptor which has the Authorization token and remove it
}
}