FFImageLoading define _authService

Hi there,

i try to implement the plugin "ffimageloading" in a little test-app, but because I'm a rookie, there is one problem with the authentication, I cannot fix.

Here is the Link of the plugin (only the part of authentication): https://github.com/luberda-molinet/FFImageLoading/wiki/Authentication-Support

So like there is written I edited

ImageService.Instance.Initialize(new Configuration
{
    HttpClient = new HttpClient(new AuthenticatedHttpImageClientHandler(_authService.GetToken))
});

in my AppDelegate, created a class, copied the snippet and added unsing-directories.

My problem is, that there is no "_authService" defined. But how can I define it? Any hints?

Best Answer

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    This class AuthenticatedHttpImageClientHandler just helps you add a user token in your header when you query a request. You need to define your own service class. This is a sample for you referring to:

    public class AuthenticationService
    {
        Func<Task<string>> getToken;
        public Func<Task<string>> GetToken
        {
            get { return getToken; }
        }
    
        public AuthenticationService()
        {
            getToken = async () =>
            {
                ...
                return "UserToken";
            };
        }
    }
    
  • MamagotchiMamagotchi Member ✭✭

    Sorry, but I don't understand this.

    I have username, password and domain and want to put it into a Token so that FFImageLoading can use it.

Sign In or Register to comment.