public static async Task <ClaimsIdentity> GenerateUserIdentityAsync(this FarmaUserManager userManager, FarmaUser user, string authenticationType)
        {
            try
            {
                // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
                var userIdentity = await userManager.CreateIdentityAsync(user, authenticationType);

                // Add custom user claims here
                return(userIdentity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private static async Task ProcessAuthToken(OAuthGrantResourceOwnerCredentialsContext context, FarmaUserManager userManager, FarmaUser user)
        {
            ClaimsIdentity oAuthIdentity =
                await userManager.GenerateUserIdentityAsync(user, OAuthDefaults.AuthenticationType);

            ClaimsIdentity cookiesIdentity =
                await userManager.GenerateUserIdentityAsync(user, CookieAuthenticationDefaults.AuthenticationType);

            AuthenticationProperties properties = CreateProperties(user);
            var ticket = new AuthenticationTicket(oAuthIdentity, properties);

            context.Validated(ticket);
            context.Request.Context.Authentication.SignIn(cookiesIdentity);
        }