0

I'm attempting to add authentication headers while loading images using the Xamarin version of the Picasso library. I see other threads for how to do it using native Android (e.g. Android Picasso library, How to add authentication headers?), however I'm not seeing the same properties and methods available in Xamarin. Has anyone accomplished this?

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();
Justin
  • 17,670
  • 38
  • 132
  • 201
  • I don't think that there's an "official" Xamarin version of Picasso, so check if the version that you are using is updated. Given that you are using Xamarin, I advise you replace Picasso with FFImageLoading https://github.com/luberda-molinet/FFImageLoading – Elton Santana Aug 01 '18 at 20:21
  • I actually just recently switched from FFImageLoading to Picasso, I kept running into bugs with FFImageLoading and there is only one developer maintaining it so you are at the mercy of their availability. – Justin Aug 02 '18 at 14:06
  • Perhaps this NuGet? https://www.nuget.org/packages/JakeWharton.Picasso2OkHttp3Downloader/ – Jon Douglas Aug 03 '18 at 20:47

0 Answers0