private async void token_session()
    {
      var settings = ApplicationData.Current.RoamingSettings;

      session = await OAuth.AuthorizeAsync((string)settings.Values["ApiKey"]

          , (string)settings.Values["ApiSecret"]);

    }
 /// <summary>
 /// 認証用トークンを取得します
 /// </summary>
 private async void InitAuth()
 {
     var bindings = DataContext as db;
     session = await OAuth.AuthorizeAsync(Twitter.CK, Twitter.CS);
     bindings.AuthUrl = session.AuthorizeUri;
     AuthLinkText.Text = session.AuthorizeUri.ToString();
     AuthLinklink.NavigateUri = session.AuthorizeUri;
     Console.WriteLine(bindings.AuthUrl.ToString());
     
     pin.IsEnabled = true;
     authButton.IsEnabled = true;
 }
Esempio n. 3
0
 private void browserOpenButton_Click(object sender, RoutedEventArgs e)
 {
     if (consumerKey.Text != string.Empty && consumerSecret.Text != string.Empty)
     {
         auth = OAuth.Authorize(consumerKey.Text, consumerSecret.Text);
         Process.Start(auth.AuthorizeUri.AbsoluteUri);
     }
     else
     {
         MessageBox.Show("CK / CS Empty!!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Esempio n. 4
0
 public async Task StartAuthentication(string consumerKey, string consumerSecret)
 {
     try
     {
         ApplicationMessageService.Instance.Messages.Add(new ApplicationMessage(ApplicationMessage.MessageType.Info, "MessageStartAuthentication", null));
         _lastSession = await OAuth.AuthorizeAsync(consumerKey, consumerSecret);
         Process.Start(_lastSession.AuthorizeUri.AbsoluteUri);
         ApplicationMessageService.Instance.Messages.Add(new ApplicationMessage(ApplicationMessage.MessageType.Info, "MessageEnterPinCode", ""));
     }
     catch (Exception ex)
     {
         ApplicationMessageService.Instance.Messages.Add(ApplicationMessage.CreateExceptionMessage(ex));
     }
 }
Esempio n. 5
0
        public Tweet()
        {
            try {

                FileStream Stream = File.OpenRead("token");

                var json = DynamicJson.Parse(Stream);

                var token = json.consumerKey;
                var secret = json.consumerSecret;
                var access = json.accessToken;
                var accessSecret = json.accessTokenSecret;

                //全て揃っていたら
                if(token != "?" && secret != "?" && access != "?" && accessSecret != "?") {

                    Tokens = CoreTweet.Tokens.Create(token, secret, access, accessSecret);
                    IsTweetButtonEnable = true;

                    return;
                }

                //コンシューマーキーのみだったら
                if(token != "" && secret != "" && access == "?") {

                    Service = OAuth.Authorize(token, secret);
                    return;
                }

                Stream.Close();

                IsTweetButtonEnable = true;
            } catch(FileNotFoundException) {

                IsTweetButtonEnable = false;
                StreamWriter writer = File.CreateText("token");
                writer.AutoFlush = true;

                dynamic json = new DynamicJson();
                json.consumerKey = "";
                json.consumerSecret = "";
                json.accessToken = "";
                json.accessTokenSecret = "";

                writer.WriteLine(json.ToString());
                writer.Close();

            }
        }
Esempio n. 6
0
        //
        // Twitterの認証を行う
        //
        public static void Auth()
        {
            MessageBox.Show("Twitter認証画面を開きます。" + Environment.NewLine + "認証を終えたら、表示された7桁の数字を記入してください。");
            session = OAuth.Authorize(Settings.Instance.ConsumerKey, Settings.Instance.ConsumerSecret);
            var url = session.AuthorizeUri;
            Process.Start(url.ToString()); // Twitter認証画面を開く

            string pin = Interaction.InputBox("7桁の数字を入力してください。", "", "", -1, -1);
            tokens = OAuth.GetTokens(session, pin);

            // 取得したトークン
            Settings.Instance.AccessToken = tokens.AccessToken;
            Settings.Instance.AccessToken_Secret = tokens.AccessTokenSecret;

            // 取得したトークンを保存
            Settings.SaveToXmlFile();
        }
    private async void initAuthrize()

    {

      try

      { 
        var settings = ApplicationData.Current.RoamingSettings;

        session = await OAuth.AuthorizeAsync((string)settings.Values["ApiKey"]

            , (string)settings.Values["ApiSecret"]);

        authWeb.Source = session.AuthorizeUri;


        //pinURITextBox.Text = session.AuthorizeUri.ToString();

        //pinTextBox.e.ClearValuer();

        // System.Diagnostics.Process.Start(session.AuthorizeUri.ToString());

      }

      catch (Exception ex)

      {
        pinTextBox.Text = "sippsi";
        // in this example we assume the parent of the UserControl is a Popup 
        Popup p = this.Parent as Popup;

        // close the Popup
        if (p != null) { p.IsOpen = false; }

        //Close();

      }

    }
Esempio n. 8
0
        public String GetAuthURL()
        {
            session = OAuth.Authorize(Properties.Settings.Default.ApiKey, Properties.Settings.Default.ApiSecret);
            return session.AuthorizeUri.ToString();

        }
Esempio n. 9
0
 public async void StartRegisteringAccount()
 {
     await Task.Run(async () =>
     {
         nowsettion = await Kbtter.CreateOAuthSession();
         View.OpenInDefault(nowsettion.AuthorizeUri);
         View.IsNewAccountPanelVisible = true;
         RegisterAccountCommand.RaiseCanExecuteChanged();
     });
 }