Пример #1
0
        public static string LoginToLogitech(string email, string password, string ipAddress, int harmonyPort)
        {
            string userAuthToken = HarmonyLogin.GetUserAuthToken(email, password);

            if (string.IsNullOrEmpty(userAuthToken))
            {
                throw new Exception("Could not get token from Logitech server.");
            }

            File.WriteAllText("UserAuthToken", userAuthToken);

            var authentication = new HarmonyAuthenticationClient(ipAddress, harmonyPort);

            string sessionToken = authentication.SwapAuthToken(userAuthToken);

            if (string.IsNullOrEmpty(sessionToken))
            {
                throw new Exception("Could not swap token on Harmony Hub.");
            }

            File.WriteAllText("SessionToken", sessionToken);

            Console.WriteLine("Date Time : {0}", DateTime.Now);
            Console.WriteLine("User Token: {0}", userAuthToken);
            Console.WriteLine("Sess Token: {0}", sessionToken);

            return(sessionToken);
        }
Пример #2
0
        private string LoginToLogitech(string userAuthToken, string ipAddress, int harmonyPort)
        {
            var authentication = new HarmonyAuthenticationClient(ipAddress, harmonyPort);

            string sessionToken = authentication.SwapAuthToken(userAuthToken);

            if (string.IsNullOrEmpty(sessionToken))
            {
                throw new Exception("Could not swap token on Harmony Hub.");
            }

            return(sessionToken);
        }
Пример #3
0
        private HarmonyClient GetHarmonyClient(User user)
        {
            return(ScopingModule.Application.Ensure <HarmonyClient>(user.ID.ToString(), () =>
            {
                var auth = new HarmonyAuthenticationClient(user.Hostname, 5222);

                string sessionToken = auth.SwapAuthToken(user.HarmonyToken);
                if (string.IsNullOrEmpty(sessionToken))
                {
                    throw new Exception("Could not swap token on Harmony Hub.");
                }

                var r = new HarmonyClient(user.Hostname, 5222, sessionToken);

                r.GetConfig();

                return r;
            }));
        }