Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.52 KB | None | 0 0
  1. private void InputButton_Click(object sender, RoutedEventArgs e)
  2.         {
  3.             if (PasswordBox.Password != String.Empty && LoginBox.Text != String.Empty)
  4.             {
  5.                 /*if (SaveLoginBox.IsChecked.Value)
  6.                     SaveLogin();
  7.                 else
  8.                     DeleteLogin();*/
  9.  
  10.                 // discover endpoints from metadata
  11.                 var client = new HttpClient();
  12.  
  13.                 var disco = client.GetDiscoveryDocumentAsync("http://localhost:5000");
  14.                 if (disco.IsFaulted)
  15.                 {
  16.                     MessageBox.Show("something wrong");
  17.                     return;
  18.                 }
  19.  
  20.                 // request token
  21.                 var tokenResponse = client.RequestPasswordTokenAsync(new PasswordTokenRequest
  22.                 {
  23.                     Address = "http://localhost:5000/connect/token",
  24.                     ClientId = "ro.client",
  25.                     ClientSecret = "secret",
  26.  
  27.                     UserName = "alice",
  28.                     Password = "Pass123$",
  29.                     Scope = "api1"
  30.  
  31.                 });
  32.  
  33.                 if (tokenResponse.IsFaulted)
  34.                 {
  35.                     MessageBox.Show("something wrong2");
  36.                     return;
  37.                 }
  38.  
  39.                 MessageBox.Show(tokenResponse.ToString());
  40.  
  41.                 AuthorizationGrid.Visibility = Visibility.Collapsed;
  42.                 MainGrid.Visibility = Visibility.Visible;
  43.                 SetDefault();
  44.             }
  45.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement