private async void OAuthButton_ClickAsync(object sender, EventArgs e) { // 操作するレジストリ・キーの名前 string registryKeyName = @"Software\MegaPad\Sub"; // 取得処理を行う対象となるレジストリの値の名前 string registryValueName = "hostname"; //キー(HKEY_CURRENT_USER\Software\Sample)を開く using (RegistryKey registryKey = Registry.LocalMachine.CreateSubKey(registryKeyName)) { // レジストリの値を設定 registryKey.SetValue(registryValueName, host); } code = OAuthInput.Text; var tokens = await ApplicaionManager.GetAccessTokenByCode(registeredApp, code); // 取得処理を行う対象となるレジストリの値の名前 registryValueName = "AccessToken"; //キー(HKEY_CURRENT_USER\Software\Sample)を開く using (RegistryKey registryKey = Registry.LocalMachine.CreateSubKey(registryKeyName)) { // レジストリの値を設定 registryKey.SetValue(registryValueName, tokens.AccessToken); } Close(); }
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; }
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; } } }