Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. var client = new HttpClient();
  2.  
  3.    
  4.     var disco = await client.GetDiscoveryDocumentAsync("https://localhost:44316/");  //sggw
  5.     if (disco.IsError)
  6.     {
  7.         Console.WriteLine(disco.Error);
  8.         Console.WriteLine("aaa");
  9.         return;
  10.     }
  11.     var tokenResponse2 = await client.RequestPasswordTokenAsync(new PasswordTokenRequest
  12.     {
  13.         Address = disco.TokenEndpoint,
  14.         UserName = "aaaa",
  15.         Password = "bbbb",
  16.         ClientId = "cccc",
  17.         ClientSecret = "ddddddd"
  18.     });
  19.  
  20.     if (tokenResponse2.IsError)
  21.     {
  22.         Console.WriteLine("bbbb");
  23.         Console.WriteLine(tokenResponse2.Error);
  24.         Console.WriteLine(tokenResponse2.ErrorDescription);
  25.         return;
  26.     }
  27.      Console.WriteLine(tokenResponse2.Json);
  28.     Console.WriteLine("\n\n");
  29.     Console.WriteLine("bearer " + tokenResponse2.Json.GetValue("access_token"));
  30.  
  31.     Thread thread = new Thread(() => Clipboard.SetText("Bearer " + tokenResponse2.Json.GetValue("access_token")));
  32.     thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA
  33.     thread.Start();
  34.     thread.Join();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement