Ejemplo n.º 1
0
        /* アプリケーションの認証処理をする関数群の実装 */
        //Client(ここではcliMa)のMastodon側への登録とTokenの取得
        private void RegistClient()
        {
            string instance, mail, passwd;

            Console.WriteLine("Application registration (first time only).");
            Console.WriteLine("Enter the instance URL.");
            instance = Console.ReadLine().ToString();
            Console.WriteLine("Enter the Email address registered with the instance.");
            mail = Console.ReadLine().ToString();
            Console.WriteLine("Enter the Password registered for the instance.");
            passwd = ReadPassword();
            var authClient = new AuthenticationClient(instance);
            var app        = authClient.CreateApp("cliMa", Scope.Read | Scope.Write | Scope.Follow).Result;
            var auth       = authClient.ConnectWithPassword(mail, passwd).Result;

            Console.WriteLine("Enter the Application Password for starting cliMa.");
            using (StreamWriter w = new StreamWriter(path))
                using (var cryptor = new Cryptor(ReadPassword()))//password input
                {
                    w.WriteLine(Convert.ToBase64String(cryptor.Encode(app.Instance)));
                    w.WriteLine(Convert.ToBase64String(cryptor.Encode(auth.AccessToken)));
                }
            Console.WriteLine("Registration completed.");
            Console.WriteLine("restarting this software.");
            Process.Start(exec_path);
            Environment.Exit(0);
        }
Ejemplo n.º 2
0
        //Mastodon側へのログイン処理とストリーム接続ソケットの引き渡し
        private MastodonClient LoginClient()
        {
            var App  = new AppRegistration();
            var Auth = new Auth();

            Console.WriteLine("Enter the Application Password for starting cliMa.");
            using (StreamReader r = new StreamReader(path))
                using (var cryptor = new Cryptor(ReadPassword()))//password input
                {
                    App.Instance     = cryptor.Decode(Convert.FromBase64String(r.ReadLine()));
                    Auth.AccessToken = cryptor.Decode(Convert.FromBase64String(r.ReadLine()));
                }
            var client = new MastodonClient(App, Auth);

            return(client);
        }