I have been breaking my brain on this one,
I am using Picasso library to load and download images from my server, but now I want to add a header in my download request and I cant seem to find a way of doing it. all i want to do is set a header like : setHeader("Authorization", "Bearer " + token);
I use this header in any of my server requests, but cant find a way to add it to the picasso line.
Any help would be appreciated, Thanks!
Picasso
usesOkHttp
as engine , or it is possible to configure Picasso to use it, and since you have to set the header of the http request, you can use anInterceptor
. E.g. this is my Interceptor to handle basic authentication:and the you add the Interceptor to OkHttp like
Last step is to configure
Picasso
to useokHttpClient
. The Picasso's builder provide a method for it :gradle dependencies: