Change retrofit okhttp client at runtime
You can add Credentials manual as Header To your request.
Example:
@GET("user")
Call<UserDetails> getUserDetails(@Header("Authorization") String credentials)
Credentials.basic("ausername","apassword");
You can use the Retrofit method newBuilder to get a new builder and there set a different OkHttpClient
with different attributes. Put something like this into your else
case:
retrofit.newBuilder()
.client(anotherOkHttpClientWithOtherAttributes.build())
.build()