I have tried setting a custom OkHttpClient with a custom Authenticator, however as the doc says: \"Responds to authentication challenges from the remote web or proxy server.
A simple way like this will keep default OkHttpClient timeout and cache configurations:
private class MyOkHttpDownloader extends OkHttpDownloader {
public MyOkHttpDownloader(final Context context) {
super(context);
getClient().interceptors().add(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request newRequest = chain.request().newBuilder()
.addHeader("X-TOKEN", "VAL")
.build();
return chain.proceed(newRequest);
}
});
}
}
Picasso picasso = new Picasso.Builder(context).downloader(new MyOkHttpDownloader(context)).build();