void AccessTokenQuery_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"]; userID = parameters["user_id"]; userScreenName = parameters["screen_name"]; MainUtil.SetKeyValue <string>("AccessToken", accessToken); MainUtil.SetKeyValue <string>("AccessTokenSecret", accessTokenSecret); MainUtil.SetKeyValue <string>("ScreenName", userScreenName); MainUtil.SetKeyValue <string>("UserID", userID); userLoggedIn(); Dispatcher.BeginInvoke(() => { AutenticaChangeColor(); //MessageBox.Show("Você está autenticado! Agora escolha a cor e acompanhe no twitter a conta @iot4dx", "MICROSOFT @ TDC 2014", MessageBoxButton.OK); }); } catch (Exception ex) { Dispatcher.BeginInvoke(() => { MessageBox.Show(ex.Message); }); } }
private void AccessTokenRequestCallback(RestRequest request, RestResponse response, object obj) { try { string respContent = response.Content; var parameters = MainUtil.GetQueryParameters(respContent); accessToken = parameters["oauth_token"]; accessTokenSecret = parameters["oauth_token_secret"]; MainUtil.SetKeyValue <string>("AccessToken", accessToken); MainUtil.SetKeyValue <string>("AccessTokenSecret", accessTokenSecret); Dispatcher.BeginInvoke(() => { // finding current user's profile getCurrentUserProfile(); }); } catch (Exception ex) { Dispatcher.BeginInvoke(() => { MessageBox.Show(ex.Message); }); } }
private void loginBrowserControl_Navigating(object sender, NavigatingEventArgs e) { if (e.Uri.ToString().StartsWith(AppSettings.CallbackUri) && e.Uri.ToString().Contains("oauth_verifier")) { var AuthorizeResult = MainUtil.GetQueryParameters(e.Uri.ToString()); var VerifyPin = AuthorizeResult["oauth_verifier"]; this.loginBrowserControl.Visibility = Visibility.Collapsed; getAccessToken(VerifyPin); } }
private void loginBrowserControl_Navigating(object sender, NavigatingEventArgs e) { try { if (e.Uri.ToString().StartsWith(TwitterSettings.CallbackUri)) { var AuthorizeResult = MainUtil.GetQueryParameters(e.Uri.ToString()); var VerifyPin = AuthorizeResult["oauth_verifier"]; this.loginBrowserControl.Visibility = Visibility.Collapsed; ContentPanel.Visibility = System.Windows.Visibility.Visible; var AccessTokenQuery = OAuthUtil.GetAccessTokenQuery(OAuthTokenKey, tokenSecret, VerifyPin); AccessTokenQuery.QueryResponse += new EventHandler <WebQueryResponseEventArgs>(AccessTokenQuery_QueryResponse); AccessTokenQuery.RequestAsync(TwitterSettings.AccessTokenUri, null); } } catch { } }
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 = TwitterSettings.AuthorizeUri + "?oauth_token=" + OAuthTokenKey; Dispatcher.BeginInvoke(() => { this.loginBrowserControl.Navigate(new Uri(authorizeUrl, UriKind.RelativeOrAbsolute)); }); } catch (Exception ex) { Dispatcher.BeginInvoke(() => { MessageBox.Show(ex.Message); }); } }