Esempio n. 1
0
        private async void LoginBrowser_Navigating(object sender, NavigatingEventArgs e)
        {
            // Hide the splash screen
            SplashScreen.Visibility = System.Windows.Visibility.Collapsed;

            if (e.Uri.AbsoluteUri.Contains("oauth.tomrudick.com"))
            {
                // Hide the browser window so the user doesn't see a bunch of OAuth redirection page flashes.
                LoginBrowser.Visibility = System.Windows.Visibility.Collapsed;

                var qs = HttpHelpers.ParseQueryString(e.Uri.Query);

                var verifier = qs["oauth_verifier"];
                var request = new RestRequest("get_access_token", Method.POST);
                client.Authenticator = OAuth1Authenticator.ForAccessToken(consumerKey, consumerSecret, this.oauth_token, this.oauth_token_secret, verifier);

                var response = await client.ExecuteRequestAsync(request);
                qs = HttpHelpers.ParseQueryString(response.Content);

                this.oauth_token = qs["oauth_token"];
                this.oauth_token_secret = qs["oauth_token_secret"];

                OAuthCredentials credentials = new OAuthCredentials() {
                    OAuthToken = this.oauth_token,
                    OAuthTokenSecret = this.oauth_token_secret,
                    OAuthVerifier = verifier
                };

                // Save to isolated storage
                storage["credentials"] = credentials;
                storage.Save();

                CompleteLogin(credentials);
            }
        }
Esempio n. 2
0
        private async void CompleteLogin(OAuthCredentials credentials)
        {
            // Set up the authenticator on the client object
            this.client.Authenticator = OAuth1Authenticator.ForProtectedResource(
                consumerKey, consumerSecret, credentials.OAuthToken, credentials.OAuthTokenSecret
            );

            await this.proxy.LoadCurrentUser();

            // Navigate to the MainPage.xaml file
            NavigationService.Navigate(new Uri("/Views/Home.xaml?HideFromBackStack=true", UriKind.Relative));
        }