我正在尝试使用Picasso库的Xamarin版本加载图像时添加身份验证标头。我看到了其他有关如何使用本机Android(例如Android Picasso library, How to add authentication headers?)进行操作的线程,但是我没有看到Xamarin中可用的相同属性和方法。有人做到了吗?
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request newRequest = chain.request().newBuilder()
.addHeader("X-TOKEN", "VAL")
.build();
return chain.proceed(newRequest);
}
})
.build();
Picasso picasso = new Picasso.Builder(context)
.downloader(new OkHttp3Downloader(client))
.build();