Ejemplo n.º 1
0
        public void RefreshTokenQuery_QueryResponse(object sender, WebQueryResponseEventArgs e)
        {
            try
            {
                StreamReader reader      = new StreamReader(e.Response);
                string       strResponse = reader.ReadToEnd();
                var          parameters  = MainUtil.GetQueryParameters(strResponse);
                accessToken       = parameters["oauth_token"];
                accessTokenSecret = parameters["oauth_token_secret"];
                TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));

                MainUtil.SetKeyValue <string>("AccessToken", accessToken);
                MainUtil.SetKeyValue <string>("AccessTokenSecret", accessTokenSecret);
                MainUtil.SetKeyValue <string>("Timestamp", t.TotalSeconds.ToString());

                userLoggedIn();
            }
            catch (Exception ex)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show(ex.Message);
                });
            }
        }
Ejemplo n.º 2
0
        private void loginBrowserControl_Navigating(object sender, NavigatingEventArgs e)
        {
            if (e.Uri.ToString().StartsWith(AppSettings.CallbackUri))
            {
                var AuthorizeResult = MainUtil.GetQueryParameters(e.Uri.ToString());
                var VerifyPin       = AuthorizeResult["oauth_verifier"];
                this.loginBrowserControl.Visibility = Visibility.Collapsed;
                var AccessTokenQuery = OAuthUtil.GetAccessTokenQuery(OAuthTokenKey, tokenSecret, VerifyPin);

                AccessTokenQuery.QueryResponse += new EventHandler <WebQueryResponseEventArgs>(AccessTokenQuery_QueryResponse);
                AccessTokenQuery.RequestAsync(AppSettings.AccessTokenUri, null);
            }
        }
Ejemplo n.º 3
0
        void requestTokenQuery_QueryResponse(object sender, WebQueryResponseEventArgs e)
        {
            try
            {
                StreamReader reader      = new StreamReader(e.Response);
                string       strResponse = reader.ReadToEnd();
                var          parameters  = MainUtil.GetQueryParameters(strResponse);
                OAuthTokenKey = parameters["oauth_token"];
                tokenSecret   = parameters["oauth_token_secret"];
                var authorizeUrl = AppSettings.AuthorizeUri + "?oauth_token=" + OAuthTokenKey;

                Dispatcher.BeginInvoke(() =>
                {
                    this.loginBrowserControl.Navigate(new Uri(authorizeUrl, UriKind.RelativeOrAbsolute));
                });
            }
            catch (Exception ex)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show(ex.Message);
                });
            }
        }