예제 #1
0
        private async void LoginBtn_Click(object sender, RoutedEventArgs e)
        {
            UserToken userToken;

            try
            {
                userToken = await OAuthClient.Authenticate();
            }
            catch (OAuthFailedException)
            {
                return;
            }

            var credentialVault = new Windows.Security.Credentials.PasswordVault();

            credentialVault.Add(new Windows.Security.Credentials.PasswordCredential("Imgur", "Username", userToken.Username));
            credentialVault.Add(new Windows.Security.Credentials.PasswordCredential("Imgur", "UserId", userToken.UserId));
            credentialVault.Add(new Windows.Security.Credentials.PasswordCredential("Imgur", "AccessToken", userToken.AccessToken));
            credentialVault.Add(new Windows.Security.Credentials.PasswordCredential("Imgur", "RefreshToken", userToken.RefreshToken));
            ApiClient.InitializeApiClient(userToken.AccessToken);
            (Window.Current.Content as Frame).Navigate(typeof(MainPage));
        }