public LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params)
        {
            var twitterService = new TwitterService(KeyStorage.Get("twitterKey"), KeyStorage.Get("twitterSecret"));

            if (String.IsNullOrEmpty(context.Request["oauth_token"]) ||
                String.IsNullOrEmpty(context.Request["oauth_verifier"]))
            {
                var requestToken = twitterService.GetRequestToken(context.Request.Url.AbsoluteUri);

                var uri = twitterService.GetAuthorizationUri(requestToken);

                context.Response.Redirect(uri.ToString(), true);
            }
            else
            {
                var requestToken = new OAuthRequestToken { Token = context.Request["oauth_token"] };
                var accessToken = twitterService.GetAccessToken(requestToken, context.Request["oauth_verifier"]);
                twitterService.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);

                var user = twitterService.VerifyCredentials(new VerifyCredentialsOptions());

                return ProfileFromTwitter(user);
            }

            return new LoginProfile();

        }
Exemplo n.º 2
0
        public static void GetUserToken(TwitterService service)
        {
            // Step 1 - Retrieve an OAuth Request Token
            OAuthRequestToken requestToken = service.GetRequestToken();

            // Step 2 - Redirect to the OAuth Authorization URL
            Uri uri = service.GetAuthorizationUri(requestToken);

            Console.WriteLine("Enter this uri into a browser:\n{0}", uri.ToString());

            Console.WriteLine("Enter the pin given by twitter");

            // Step 3 - Exchange the Request Token for an Access Token
            string verifier = Console.ReadLine(); // <-- This is input into your application by your user
            OAuthAccessToken access = service.GetAccessToken(requestToken, verifier);

            if(access == null)
            {
                Console.WriteLine("no tokens returned");
                return;
            }

            Console.WriteLine("Access Token:\n{0}", access.Token);
            Console.WriteLine("Access Secret:\n{0}", access.TokenSecret);

            // Step 4 - User authenticates using the Access Token
            service.AuthenticateWith(access.Token, access.TokenSecret);
        }
Exemplo n.º 3
0
        public IEnumerable<TwitterStatus> GetFavorites()
        {
            var service = new TwitterService(Config.Twitter.ConsumerKey, Config.Twitter.ConsumerSecret);

            // Step 1 - Retrieve an OAuth Request Token
            var requestToken = service.GetRequestToken();

            // Step 2 - Redirect to the OAuth Authorization URL
            var uri = service.GetAuthorizationUri(requestToken);
            Process.Start(uri.ToString());

            // Step 3 - Exchange the Request Token for an Access Token
            Console.Write("Please, your key? ");
            var verifier = Console.ReadLine(); // <-- This is input into your application by your user
            var access = service.GetAccessToken(requestToken, verifier);

            // Step 4 - User authenticates using the Access Token
            service.AuthenticateWith(access.Token, access.TokenSecret);

            var users = service.SearchForUser("kellogh");
            if (users == null)
            {
                Console.WriteLine("No users found");
                yield break;
            }

            var user = users.First();

            var favorites = service.ListFavoriteTweetsFor(user.Id);

            foreach (var tweet in favorites)
            {
                yield return tweet;
            }
        }
Exemplo n.º 4
0
        public Tweeter()
        {
            var _consumerKey = "J9iaXHK7R0bpKiRabxQ";
            var _consumerSecret = "Xs6XJggEvXtMVDvaYAvTLnIm13G70ymcdhwQ3J1M";

            // this authentication snippet borrowed from https://github.com/danielcrenna/tweetsharp

            service = new TwitterService(_consumerKey, _consumerSecret);

            // Step 1 - Retrieve an OAuth Request Token
            OAuthRequestToken requestToken = service.GetRequestToken();

            // Step 2 - Redirect to the OAuth Authorization URL
            // Uri uri = service.GetAuthorizationUri(requestToken);
            // Process.Start(uri.ToString());

            // Step 3 - Exchange the Request Token for an Access Token

            // OAuthAccessToken access = service.GetAccessToken(requestToken, verifier);
            // OAuthAccessToken generated manually through dev.twitter.com so no need for this bit since it's just me tweetin ma shit

            var access = new OAuthAccessToken();
            access.Token = "1196853272-YbSEB0Mnaj6lK3tOKGQ8nwOVLnfhXldwqjlzNmk";
            access.TokenSecret = "4BHhe3iUdlh6o2Re0OmMq3v6e8OwH9vw149MEPR3I";

            // Step 4 - User authenticates using the Access Token
            service.AuthenticateWith(access.Token, access.TokenSecret);
            // service.SendTweet(new SendTweetOptions { Status = "Hello World" });
        }
Exemplo n.º 5
0
 public ActionResult Login(string returnUrl)
 {
     var service = new TwitterService(ConsumerKey, ConsumerSecret);
     var requestToken = service.GetRequestToken(Url.Action("LoginCallback", "Auth", new {returnUrl}, Request.Url.Scheme));
     var uri = service.GetAuthorizationUri(requestToken);
     return Redirect(uri.ToString());
 }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            var _consumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"].ToString();
            var _consumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"].ToString();

            // configure access token
            //var _accessToken = ConfigurationManager.AppSettings["twitterAccess"].ToString();
            //var _accessTokenSecret = ConfigurationManager.AppSettings["twitterAccessSecret"].ToString();

            service = new TwitterService(_consumerKey, _consumerSecret);

            // Step 1 - Retrieve an OAuth Request Token
            OAuthRequestToken requestToken = service.GetRequestToken();

            // Step 2 - Redirect to the OAuth Authorization URL
            Uri uri = service.GetAuthorizationUri(requestToken);
            Process.Start(uri.ToString());

            // Step 3 - Exchange the Request Token for an Access Token
            string verifier = "123456"; // <-- This is input into your application by your user
            OAuthAccessToken access = service.GetAccessToken(requestToken, verifier);

            // Step 4 - User authenticates using the Access Token
            service.AuthenticateWith(access.Token, access.TokenSecret);

            //service.AuthenticateWith(_accessToken, _accessTokenSecret);

            //SendATweet();
            //GeoLocationLookup();
            ListFollowers();

            Console.ReadKey();
        }
        public Uri GetAutheticationUri(IDictionary<string, string> parameters, Uri callback)
        {
            var callbackUri = new UriBuilder(callback)
            {
                Query = string.Format("context={0}", parameters["wctx"])
            };

            // Pass your credentials to the service
            string consumerKey = _settings.TwitterConsumerKey;
            string consumerSecret = _settings.TwitterConsumerSecret;

            var service = new TwitterService(consumerKey, consumerSecret);

            // Retrieve an OAuth Request Token
            string returnUri = callbackUri.ToString();
            OAuthRequestToken requestToken;

            try
            {
                requestToken = service.GetRequestToken(returnUri);
            }
            catch (ArgumentException e)
            {
                string message = string.Format("Failed to request twitter auth token, code: {0}, exception: {1}", service.Response.StatusCode, service.Response.InnerException);
                throw new ArgumentException(message, e);
            }

            // Redirect to the OAuth Authorization URL
            return service.GetAuthorizationUri(requestToken);
        }
Exemplo n.º 8
0
 public static string GetAuthorizationUri()
 {
     var service = new TwitterService(ConsumerToken.ConsumerKey,
         ConsumerToken.ConsumerSecret);
     var requestToken = service.GetRequestToken();
     var uri = service.GetAuthorizationUri(requestToken, "http://127.0.0.1:1400/#/twitter-tokens'");
     return uri.ToString();
 }
        public void CanGetRequestToken()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            var requestToken = service.GetRequestToken();

            Assert.AreEqual(service.Response.StatusCode, HttpStatusCode.OK);
            Assert.IsNotNull(requestToken);
        }
Exemplo n.º 10
0
        public OAuth()
        {
            _consumerKey = ConfigurationManager.AppSettings["ConsumerKey"];
            _consumerSecret = ConfigurationManager.AppSettings["ConsumerSecret"];
            TwitterService service = new TwitterService(_consumerKey, _consumerSecret);

            _requestToken = service.GetRequestToken();
            _uri = service.GetAuthorizationUri(_requestToken);
        }
Exemplo n.º 11
0
 private void InitializeNewSession()
 {
     _twitterClientInfo = new TwitterClientInfo();
     _twitterClientInfo.ConsumerKey = "2yeyhTAMl3Euzc2aXSlOA"; //TODO: get this value especially for adidas
     _twitterClientInfo.ConsumerSecret = "8yXVBamNBfd82hSbCbBNWPQvto0cjgqVjYuBbLXm0";
         //TODO: get this value especially for adidas
     _twitterService = new TwitterService(_twitterClientInfo);
     _requestToken = _twitterService.GetRequestToken();
 }
Exemplo n.º 12
0
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     _twitterService = new TwitterService(Constants.ConsumerKey,
         Constants.ConsumerSecret);
     _requestToken = _twitterService.GetRequestToken();
     //_applicationCredentials = CredentialsCreator.GenerateApplicationCredentials);
     _url = _twitterService.GetAuthorizationUri(_requestToken).ToString();
 }
Exemplo n.º 13
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.º 14
0
        public ActionResult Authorize()
        {
            // Step 1: Retrieve an OAuth Request Token
            _service = new TwitterService(key, secret);
            OAuthRequestToken requestToken = _service.GetRequestToken("http://localhost:9090/AuthorizeCallback");

            // Step 2: Redirect to the OAuth Authorization URL
            Uri uri = _service.GetAuthorizationUri(requestToken);
            return new RedirectResult(uri.ToString(), false /*permanent*/);
        }
 private static TwitterService GetTwitterService(Tuple<string, string> authKeys)
 {
     TwitterService service = new TwitterService(authKeys.Item1, authKeys.Item2);
     OAuthRequestToken requestToken = service.GetRequestToken();
     Uri uri = service.GetAuthorizationUri(requestToken);
     var taw = new TwitterAuth() { AuthUrl = uri };
     taw.ShowDialog();
     OAuthAccessToken access = service.GetAccessToken(requestToken, taw.Token);
     service.AuthenticateWith(access.Token, access.TokenSecret);
     return service;
 }
Exemplo n.º 16
0
        public ActionResult GetConnectedWithTwitter()
        {
            string _consumerKey = System.Configuration.ConfigurationManager.AppSettings["consumerKeyLogin"];
            string _consumerSecret = System.Configuration.ConfigurationManager.AppSettings["consumerSecretLogin"];
            TwitterService service = new TwitterService(_consumerKey, _consumerSecret);

            OAuthRequestToken requestToken = service.GetRequestToken();

            var uri = service.GetAuthorizationUri(requestToken);
            return new RedirectResult(uri.ToString(), false /*permanent*/);
        }
Exemplo n.º 17
0
        protected void btnSignInToTwitter_Click(object sender, EventArgs e)
        {
            // Step 1 - Retrieve an OAuth Request Token
            TwitterService service = new TwitterService(Global.TwitterConsumerKey, Global.TwitterConsumerSecret);

            // This is the registered callback URL
            OAuthRequestToken requestToken = service.GetRequestToken("http://" + Request.Url.Host + ":" + Request.Url.Port + "/api/TwAuthCallback.ashx");

            // Step 2 - Redirect to the OAuth Authorization URL
            Uri uri = service.GetAuthorizationUri(requestToken);
            Response.Redirect(uri.ToString());
        }
        public string GetLoginUrl()
        {
            // Step 1 - Retrieve an OAuth Request Token
            var service = new TwitterService(ConfigurationManager.AppSettings["twitterConsumerKey"], ConfigurationManager.AppSettings["twitterConsumerSecret"]);

            // This is the registered callback URL
            var requestToken = service.GetRequestToken(ConfigurationManager.AppSettings["twitterCallbackUrl"]);

            // Step 2 - Redirect to the OAuth Authorization URL
            var uri = service.GetAuthorizationUri(requestToken);
            return uri.ToString();
        }
Exemplo n.º 19
0
        private void launchTwitterAppButton_Click(object sender, RoutedEventArgs e)
        {
            // Pass your credentials to the service
            service = new TwitterService("rfeDMlcxMQSqDSdmXDT3A", "7ZUD4YtVqOfFJcCHwWz7q0qTFjcKyVGSNyN4ElCsZZE");

            // Step 1 - Retrieve an OAuth Request Token
            requestToken = service.GetRequestToken();

            // Step 2 - Redirect to the OAuth Authorization URL
            Uri uri = service.GetAuthorizationUri(requestToken);
            Process.Start(uri.ToString());
        }
Exemplo n.º 20
0
        // Based on samples taken from https://github.com/danielcrenna/tweetsharp
        public ActionResult Authorize()
        {
            // Step 1 - Retrieve an OAuth Request Token
            TwitterService service = new TwitterService(ConfigurationManager.AppSettings["TwitterConsumerKey"], ConfigurationManager.AppSettings["TwitterConsumerSecret"]);

            // This is the registered callback URL
            OAuthRequestToken requestToken = service.GetRequestToken(ConfigurationManager.AppSettings["TwitterCallbackUrl"]);

            // Step 2 - Redirect to the OAuth Authorization URL
            Uri uri = service.GetAuthorizationUri(requestToken);
            return new RedirectResult(uri.ToString(), false /*permanent*/);
        }
Exemplo n.º 21
0
        /****
        Twitter API
        ****/
        public ActionResult Authorize()
        {
            // Retrieve OAuth Request Token
            TwitterService service = new TwitterService(_consumerKey, _consumerSecret);

            // Callback URL
            OAuthRequestToken requestToken = service.GetRequestToken("http://localhost:62488/AuthorizeCallback");

            // Redirect to the OAuth Authorization URL
            Uri uri = service.GetAuthorizationUri(requestToken);
            return new RedirectResult(uri.ToString(), false /*permanent*/);
        }
Exemplo n.º 22
0
        public ActionResult Authorize()
        {
            var twitterService = new TwitterService(TwitterAuthentication.Key, TwitterAuthentication.Secret);

            var requestToken = twitterService.GetRequestToken();

            Session["RequestToken"] = requestToken;

            var uri = twitterService.GetAuthorizationUri(requestToken);

            return new RedirectResult(uri.ToString());
        }
        public ActionResult AuthorizeTwitter()
        {
            TwitterService service = new TwitterService(_twitterAuthKey, _twitterConsumerSecret);

            string redirectUri;

            redirectUri = "https://api.dareme.to/Onboard/CompleteTwitter/";

            OAuthRequestToken requestToken = service.GetRequestToken(redirectUri);

            Uri uri = service.GetAuthorizationUri(requestToken);
            return new RedirectResult(uri.ToString(), false);
        }
Exemplo n.º 24
0
        public ActionResult Auth()
        {
            // Step 1 - Retrieve an OAuth Request Token
            TwitterService service = new TwitterService(TwitterConsumerKey, TwitterConsumerSecret);

            // This is the registered callback URL
            OAuthRequestToken requestToken = service.GetRequestToken(ConfigurationManager.AppSettings["uri"] + "Twitter/AuthorizeCallback");
            // OAuthRequestToken requestToken = service.GetRequestToken("http://localhost:65413/Twitter/AuthorizeCallback");

            // Step 2 - Redirect to the OAuth Authorization URL
            Uri uri = service.GetAuthorizationUri(requestToken);
            return new RedirectResult(uri.ToString(), false /*permanent*/);
        }
        public ActionResult Authorize()
        {
            // Step 1 - Retrieve an OAuth Request Token
            TwitterService service = new TwitterService(TwitterSettings.ConsumerKey, TwitterSettings.ConsumerSecret);

            // This is the registered callback URL
            OAuthRequestToken requestToken = service.GetRequestToken("http://dimitar-dev/Home/AuthorizeCallback");

            // Step 2 - Redirect to the OAuth Authorization URL
            Uri uri = service.GetAuthorizationUri(requestToken);

            return new RedirectResult(uri.ToString(), false /*permanent*/);
        }
Exemplo n.º 26
0
        private void button2_Click(object sender, EventArgs e)
        {
            Form1 f = this.Owner as Form1;
            // Pass your credentials to the service
            service = new TwitterService(f.AppAccessToken, f.AppAccessTokenSecret);

            // Step 1 - Retrieve an OAuth Request Token
            requestToken = service.GetRequestToken();

            // Step 2 - Redirect to the OAuth Authorization URL
            Uri uri = service.GetAuthorizationUri(requestToken);
            System.Diagnostics.Process.Start(uri.ToString());
        }
Exemplo n.º 27
0
        public AuthorizeTwitter()
        {
            TwitterClientInfo twitterClientInfo = new TwitterClientInfo();
            twitterClientInfo.ConsumerKey = ConsumerKey; //Read ConsumerKey out of the app.config
            twitterClientInfo.ConsumerSecret = ConsumerSecret; //Read the ConsumerSecret out the app.config

            TwitterService twitterService = new TwitterService(twitterClientInfo);
            if (string.IsNullOrEmpty(AccessToken) || string.IsNullOrEmpty(AccessTokenSecret))
            {
                //Now we need the Token and TokenSecret

                //Firstly we need the RequestToken and the AuthorisationUrl
                OAuthRequestToken requestToken = twitterService.GetRequestToken();
                Uri authUrl = twitterService.GetAuthorizationUri(requestToken);

                //authUrl is just a URL we can open IE and paste it in if we want
                Console.WriteLine("Please Allow This App to send Tweets on your behalf");
                Process.Start(authUrl.ToString()); //Launches a browser that'll go to the AuthUrl.

                //Allow the App
                Console.WriteLine("Enter the PIN from the Browser:");
                string pin = Console.ReadLine();

                OAuthAccessToken accessToken = twitterService.GetAccessToken(requestToken, pin);

                string token = accessToken.Token; //Attach the Debugger and put a break point here
                string tokenSecret = accessToken.TokenSecret; //And another Breakpoint here

                Console.WriteLine("Write Down The AccessToken: " + token);
                Console.WriteLine("Write Down the AccessTokenSecret: " + tokenSecret);

            }

            twitterService.AuthenticateWith(AccessToken, AccessTokenSecret);
            //twitterService.SendTweet("A Simple Tweet from a Simple Twitter Client");
            //Console.WriteLine("Enter a Tweet");
            //string tweetMessage;

            //while (true)
            //{
            //    tweetMessage = Console.ReadLine();
            //    if (tweetMessage.ToLower() == "exit")
            //    {
            //        break;
            //    }
            //    twitterService.SendTweet(tweetMessage);
            //}

            var x = twitterService.ListFollowerIdsOf("_glynster_",-1);
        }
        public TwitterAccessService()
        {
            var ConsumerKey = "XYibQ9TLaR9ygaOSk5kqew";
                var ConsumerSecret = "nULuAiTRU9hpPx5PbjyNbU36kilcNZ5vKhgMdJFx2A";
                var AccessToken = "105040957-NGNdU4VzIZLhxcuABIq3AS5BfmVTuO8Ai8srcZmI";
                var AccessTokenSecret = "d2s6kIXSE9GcK31bSjTR6QGElgtbUJitGPP8uP1k5pY";

                // Pass your credentials to the service
                service = new TwitterService(ConsumerKey, ConsumerSecret);

                //Retrieve an OAuth Request Token
                token = service.GetRequestToken();

                //Authenticates using the Access Token
                service.AuthenticateWith(AccessToken, AccessTokenSecret);
        }
Exemplo n.º 29
0
    private void ApplicationStartUpHandler(object sender, StartupEventArgs e)
    {
      service = new TwitterService(TwitterConstants.ConsumerKey, TwitterConstants.ConsumerSecret);


      // Step 1 - Retrieve an OAuth Request Token
      requestToken = service.GetRequestToken();

      // Step 2 - Redirect to the OAuth Authorization URL
      Uri uri = service.GetAuthorizationUri(requestToken);
      Process.Start(uri.ToString());
      //
      //      // Step 3 - Exchange the Request Token for an Access Token

      var authWindow = new AuthenticationWindow(service, requestToken);
      authWindow.Show();
      //      authWindow.Browser.Navigated += Browser_Navigated;
    }
Exemplo n.º 30
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!editMode)
            {
                TwitterService service = new TwitterService("9fHcTGpQkdy25gAQ8bFmiOd67", "KBWAa7reZWDEofMkgDluIfLVk9dEaAZAOTinUFInw5k6xNGCX6");

                // Step 1 - Retrieve an OAuth Request Token
                OAuthRequestToken requestToken = service.GetRequestToken();

                // Step 2 - Redirect to the OAuth Authorization URL
                Uri uri = service.GetAuthorizationUri(requestToken);
                Process.Start(uri.ToString());

                // Step 3 - Exchange the Request Token for an Access Token
                string verifier = "0350060"; // <-- This is input into your application by your user
                OAuthAccessToken access = service.GetAccessToken(requestToken, verifier);

                // Step 4 - User authenticates using the Access Token
                service.AuthenticateWith(access.Token, access.TokenSecret);

                var aluno = new Aluno((Turma)Enum.Parse(typeof(Turma), cbxTurma.Text),
                        txtNome.Text,
                        txtSobrenome.Text,
                        int.Parse(txtIdade.Text),
                        double.Parse(txtNota.Text),
                        (Status)Enum.Parse(typeof(Status), cbxStatus.Text));
                _alunoAplicacao.Adicionar(aluno);

                service.BeginSendTweet(new SendTweetOptions());
            }

            else
            {
                var aluno = _alunoAplicacao.Buscar(_aluno.Id);
                aluno.Turma = (Turma)Enum.Parse(typeof(Turma), cbxTurma.Text);
                aluno.Nome = txtNome.Text;
                aluno.Sobrenome = txtSobrenome.Text;
                aluno.Idade = int.Parse(txtIdade.Text);
                aluno.Nota = double.Parse(txtNota.Text);
                aluno.Status = (Status)Enum.Parse(typeof(Status), cbxStatus.Text);
                _alunoAplicacao.Atualizar(aluno);
            }
            Close();
        }