private async void SignIn_Click(object sender, RoutedEventArgs e)
        {
            var error = string.Empty;

            try
            {
                var response = await WebAuthentication.DoImplicitFlowAsync(
                    endpoint : new Uri(Constants.IdSrv.OAuth2AuthorizeEndpoint),
                    clientId : Constants.IdSrv.Win8OAuthClientName,
                    scope : Constants.Scope);

                TokenVault.StoreToken(_resourceName, response);
                RetrieveStoredToken();
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }

            if (!string.IsNullOrEmpty(error))
            {
                var dialog = new MessageDialog(error);
                await dialog.ShowAsync();
            }
        }
Example #2
0
        private async void ButtonRequestToken_Click(object sender, RoutedEventArgs e)
        {
            var error = string.Empty;

            try
            {
                var response = await WebAuthentication.DoImplicitFlowAsync(
                    endpoint : new Uri(Constants.AS.OAuth2AuthorizeEndpoint),
                    clientId : Constants.Clients.ImplicitClient,
                    scope : "read");

                TokenVault.StoreToken(_resourceName, response.AccessToken, response.ExpiresIn, response.TokenType);
                RetrieveStoredToken();
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }

            if (!string.IsNullOrEmpty(error))
            {
                var dialog = new MessageDialog(error);
                await dialog.ShowAsync();
            }
        }
        private async void SignIn_Click(object sender, RoutedEventArgs e)
        {
            var error = string.Empty;

            try
            {
                var response = await WebAuthentication.DoImplicitFlowAsync(
                    endpoint : new Uri("https://adfs.leastprivilege.vm/idsrv/issue/oauth2/authorize"),
                    clientId : "test",
                    scope : "https://test/rp/");

                TokenVault.StoreToken(_resourceName, response);
                RetrieveStoredToken();
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }

            if (!string.IsNullOrEmpty(error))
            {
                var dialog = new MessageDialog(error);
                await dialog.ShowAsync();
            }
        }
        private void RetrieveStoredToken()
        {
            TokenCredential credential;

            if (TokenVault.TryGetToken(_resourceName, out credential))
            {
                _credential      = credential;
                _txtToken.Text   = credential.AccessToken;
                _txtExpires.Text = credential.Expires.ToString();
            }
        }