Exemplo n.º 1
0
        public ActionResult Authorize()
        {
            // Step 1 - Retrieve an OAuth Request Token
            TwitterService service = new TwitterService(AuthenticationTokens.TwitterConsumerKey, AuthenticationTokens.TwitterConsumerSecret);
            OAuthRequestToken requestToken = service.GetRequestToken("http://localhost:63516/Account/AuthorizeCallback"); // <-- The registered callback URL

            // Step 2 - Redirect to the OAuth Authorization URL
            Uri uri = service.GetAuthenticationUrl(requestToken);
            return new RedirectResult(uri.ToString(), false /*permanent*/);
        }
Exemplo n.º 2
0
 private void authTwitter(TwitterService twitterService)
 {
     string authUri = twitterService.GetAuthenticationUrl(requestToken).ToString();
     System.Diagnostics.Process.Start(authUri.ToString());
     SettingsManager SM = new SettingsManager();
     SM.ShowDialog();
     pin = SM.twitterPIN;
     oAccessToken = twitterService.GetAccessToken(requestToken, pin);
     AdvancedSoftwareProject.Properties.Settings.Default.AccessToken = oAccessToken.Token;
     AdvancedSoftwareProject.Properties.Settings.Default.AccessTokenSecret = oAccessToken.TokenSecret;
     AdvancedSoftwareProject.Properties.Settings.Default.Save();
     twitterService.AuthenticateWith(AdvancedSoftwareProject.Properties.Settings.Default.AccessToken, AdvancedSoftwareProject.Properties.Settings.Default.AccessTokenSecret);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Open twitter auth page
        /// </summary>
        private void tw_connection()
        {
            TwitterService twService = new TwitterService(SWTwitterSettings.ConsumerKey,
            SWTwitterSettings.ConsumerSecret);
              twService.GetRequestToken((token, response) =>
              {
            // Handle errors
            if (token == null)
            {
              Deployment.Current.Dispatcher.BeginInvoke(() =>
              {
            displayErrorAndGoBack("Cannot authorize Twitter." + Environment.NewLine
              + "Please check your internet");
              });
              System.Diagnostics.Debug.WriteLine(response.Response);
              return;
            }

            // Save request token
            this.tw_requestToken = token;

            // Navigate to auth page
            Uri uri = twService.GetAuthenticationUrl(token);
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
              System.Diagnostics.Debug.WriteLine(uri.ToString());
              authBrowser.Navigate(uri);
            });
              });
        }