现在改造已经发布了2.0.0,这是我的解决方案:
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
String uid = "0";
long timestamp = (int) (Calendar.getInstance().getTimeInMillis() / 1000);
String signature = MD5Util.crypt(timestamp + "" + uid + MD5_SIGN);
String base64encode = signature + ":" + timestamp + ":" + uid;
base64encode = Base64.encodeToString(base64encode.getBytes(), Base64.NO_WRAP | Base64.URL_SAFE);
Request request = chain.request();
HttpUrl url = request.url()
.newBuilder()
.addQueryParameter("pageSize", "2")
.addQueryParameter("method", "getAliasList")
.build();
request = request
.newBuilder()
.addHeader("Authorization", "zui " + base64encode)
.addHeader("from_client", "ZuiDeer")
.url(url)
.build();
Response response = chain.proceed(request);
return response;
}
}).build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(ApiConstants.API_BASE_URL)
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
mRestfulService = retrofit.create(RestfulService.class);