Esempio n. 1
0
        public void CreateAppAndAuth()
        {
            var app = ApplicaionManager.RegistApp(Host, AppName, Scope.Read).Result;
            var url = ApplicaionManager.GetOAuthUrl(app);

            Console.WriteLine("Open " + url);
            System.Diagnostics.Process.Start(url);
            Console.WriteLine("Please accept the request to access your account on opened web browser.");
            Console.Write("And copy and paste the displayed code here: ");
            var code = Console.ReadLine();

            Tokens = ApplicaionManager.GetAccessTokenByCode(app, code).Result;
        }
Esempio n. 2
0
        public void GenerateButton_Click(object sender, EventArgs e)
        {
            host = InstanceInput.Text;
            if (InstanceInput.Text == "misskey.xyz")
            {
                // 操作するレジストリ・キーの名前
                string registryKeyName = @"Software\MegaPad\Sub";
                // 取得処理を行う対象となるレジストリの値の名前
                string registryValueName = "hostname";

                //キー(HKEY_CURRENT_USER\Software\Sample)を開く
                using (RegistryKey registryKey = Registry.LocalMachine.CreateSubKey(registryKeyName))
                {
                    // レジストリの値を設定
                    registryKey.SetValue(registryValueName, "misskey.xyz");
                }

                // 取得処理を行う対象となるレジストリの値の名前
                registryValueName = "AccessToken";

                //キー(HKEY_CURRENT_USER\Software\Sample)を開く
                using (RegistryKey registryKey = Registry.LocalMachine.CreateSubKey(registryKeyName))
                {
                    // レジストリの値を設定
                    registryKey.SetValue(registryValueName, "misskey is not need token");
                }

                main.OAuthMisskeyAsync();
                Close();
            }
            else
            {
                try
                {
                    registeredApp = ApplicaionManager.RegistApp(host, "MegaPad", Scope.Read | Scope.Write | Scope.Follow).Result;
                }
                catch (AggregateException)
                {
                    MessageBox.Show("インスタンスを取得できませんでした。正しいインスタンスの名前か確認してください。",
                                    "エラー",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                var url = ApplicaionManager.GetOAuthUrl(registeredApp);

                OAuthlink.Text = url;
            }
        }
Esempio n. 3
0
        private void OAuth()
        {
            var registeredApp = ApplicaionManager.RegistApp("qiitadon.com", "MastCondot", Scope.Read | Scope.Write | Scope.Follow).Result;
            //var registeredApp = ApplicaionManager.RegistApp("pawoo.net", "MastCondot", Scope.Read | Scope.Write | Scope.Follow).Result;
            var url = ApplicaionManager.GetOAuthUrl(registeredApp);

            Console.WriteLine(url);
            Console.Write("please copy and peaste AccessToken:");
            var code   = Console.ReadLine();
            var tokens = ApplicaionManager.GetAccessTokenByCode(registeredApp, code).Result;

            Console.WriteLine(tokens.AccessToken);
            var url1 = "https://qiitadon.com";

            url = "https://streaming.qiitadon.com:4000";
            //url = "https://pawoo.net/web/timelines/home";
            Console.WriteLine("OAuthSuccess!");

            var p = new Program();

            for (; ;)
            {
                Console.WriteLine("May I help you?(readmode: r, tootmode: t, exit: other):");
                var answer = Console.ReadLine();
                if (answer == "r")
                {
                    p.Read(url, tokens.AccessToken);
                }
                else if (answer == "t")
                {
                    Console.Write("Please Write to send Toot:");
                    var content = Console.ReadLine();
                    p.Toot(url1, tokens.AccessToken, content);
                }
                else
                {
                    break;
                }
            }
        }