locked
FFImageLoading define _authService RRS feed

  • Question

  • User368700 posted

    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?

    Sunday, December 16, 2018 9:49 PM

Answers

  • User369979 posted

    Try to use your username and password to access your web service, then your server could return a token for using. Add this token in the mthod I post above. Your server can retreve that token in the request's header. Its key is Authorization:

    getToken = async () =>
    {
       ...// Query token from your server
       return "UserToken";
    };
    

    You can also encrypt your username and password to a token string, then posting that to the server could be another workaround. Use the same key to retrieve the token you written in the AuthenticatedHttpImageClientHandler class.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, December 17, 2018 9:06 AM

All replies

  • User369979 posted

    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";
            };
        }
    }
    
    Monday, December 17, 2018 6:52 AM
  • User368700 posted

    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.

    Monday, December 17, 2018 8:17 AM
  • User369979 posted

    Try to use your username and password to access your web service, then your server could return a token for using. Add this token in the mthod I post above. Your server can retreve that token in the request's header. Its key is Authorization:

    getToken = async () =>
    {
       ...// Query token from your server
       return "UserToken";
    };
    

    You can also encrypt your username and password to a token string, then posting that to the server could be another workaround. Use the same key to retrieve the token you written in the AuthenticatedHttpImageClientHandler class.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, December 17, 2018 9:06 AM