Beispiel #1
0
        public static void AddAuthenticationUser(string clientId, string clientSecret)
        {
            var authResponse = TwitchAuthentication.Authenticate(clientId, clientSecret, url => {
                TwitchAuthenticationWindow authentWindow = new TwitchAuthenticationWindow(url);
                authentWindow.ShowDialog();

                return(authentWindow.Url);
            });

            if (authResponse is SuccessfulAuthentication success)
            {
                MainAdmin.TwitchUserTokenDict.Add(success.Name, success.Token);
            }
        }
Beispiel #2
0
        private static Client AuthenticateLogin(string[] args)
        {
            Console.WriteLine("Login user: "******"Too few arguments!");
                    Console.WriteLine("Usage: {0} <client id> <client secret>", Environment.GetCommandLineArgs()[0]);
                    Environment.Exit(1);
                    return(null);
                }

                string clientId     = args[0];
                string clientSecret = args[1];

                authResponse = TwitchAuthentication.Authenticate(clientId, clientSecret, url => {
                    Console.WriteLine("Log in URL:");
                    Console.WriteLine(url);
                    return(Console.ReadLine());
                });
                newToken = true;
            }

            if (authResponse is SuccessfulAuthentication success)
            {
                // When new Token add Token to DB
                if (newToken)
                {
                    MainAdmin.AddAccesToken(success.Name, success.Token);
                }

                Console.WriteLine("Authentication Success");

                CliClientHandler clientHandler = new CliClientHandler();
                Client           client        = new Client(success.Name, success.Token, clientHandler);
                client.Connect();

                return(client);
            }
            else
            {
                var failure = authResponse as FailedAuthentication;
                Console.WriteLine("Authentication Failure: {0}; Reason: {1}", failure.Failure, failure.Reason);

                Console.ReadKey();
            }
            return(null);
        }