Exemple #1
0
        private void ButtonAuthenticate_Click(object sender, EventArgs e)
        {
            if (AuthTokenResponse == null)
            {
                AppendLineToOutput("Already authenticated. Check ratelimiting details.");
                return;
            }

            AuthTokenResponse = OAuthUtility.GetAccessToken(Settings.Default.ConsumerKey,
                                                            Settings.Default.ConsumerSecret,
                                                            AuthTokenResponse.Token,
                                                            TextBoxInput.Text);

            var tokenResponse = AuthTokenResponse;

            Settings.Default.UserAccessToken  = tokenResponse.Token;
            Settings.Default.UserAccessSecret = tokenResponse.TokenSecret;
            Settings.Default.Save();

            Tokens.AccessToken       = Settings.Default.UserAccessToken;
            Tokens.AccessTokenSecret = Settings.Default.UserAccessSecret;

            CommandManagement.Init(this, Tokens);

            AppendLineToOutput("Authentication succeeded.");
        }
Exemple #2
0
        public FormMain()
        {
            InitializeComponent();

            //this.Text = this.Text + System.IO.Path.g(Environment.CurrentDirectory);
            //this.Text += "::" + .GetFileName(GetDirectoryName(Application.ExecutablePath);

            this.toolStripMenuItemPath.Text = Path.GetDirectoryName(Application.ExecutablePath);

            this.Text += string.Format(":: (opened from {0})", Path.GetFileName(Path.GetDirectoryName(Application.ExecutablePath)));

            this.ContextMenuStrip = contextMenuStripMain;
            this.TextBoxInput.ContextMenuStrip     = contextMenuInput;
            this.flowLayoutPanel1.ContextMenuStrip = contextMenuRadio;

            Tokens = new OAuthTokens
            {
                ConsumerKey    = Settings.Default.ConsumerKey,
                ConsumerSecret = Settings.Default.ConsumerSecret
            };

            if (!string.IsNullOrEmpty(Settings.Default.UserAccessToken) && !string.IsNullOrEmpty(Settings.Default.UserAccessSecret))
            {
                Tokens.AccessToken       = Settings.Default.UserAccessToken;
                Tokens.AccessTokenSecret = Settings.Default.UserAccessSecret;
            }
            else
            {
                AuthTokenResponse = OAuthUtility.GetRequestToken(Settings.Default.ConsumerKey, Settings.Default.ConsumerSecret, "oob");

                TextBoxInput.Text = "Enter pin here. Make sure the pin is the only text in this textbox. Click Authenticate.";

                Process process = new Process();
                process.StartInfo.FileName  = getDefaultBrowser();
                process.StartInfo.Arguments = "http://twitter.com/oauth/authorize?oauth_token=" + AuthTokenResponse.Token;
                process.Start();
            }

            CommandManagement.Init(this, Tokens);
        }