Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net.Http;
  5. using System.Net.Http.Headers;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using IdentityModel.Client;
  9.  
  10. namespace ConsoleApp41
  11. {
  12. class Program
  13. {
  14. static void Main(string[] args)
  15. {
  16.  
  17. Run().Wait();
  18. }
  19.  
  20. public static async Task Run()
  21. {
  22. var baseUrl = "http://lab03-wa1:5204/";
  23. var api = "http://lab03-wa1/sso";
  24. var tokenClient = new TokenClient($"{api}/connect/token/", "public_api_intg", "10D41201-5DE0-45EA-B7C6-56205164836F");
  25. var cred = await tokenClient.RequestClientCredentialsAsync("reference_data data_service position_api");
  26. string companyCode = "";
  27. string userName = "";
  28. string accountCode = "";
  29. string currencyCode = "";
  30. DateTime executionDate = DateTime.Now;
  31. var relativeUrl = $"/v2/custodians";
  32. using (var client = CreateHttpClient(relativeUrl))
  33. {
  34. client.BaseAddress = new Uri(baseUrl);
  35. var result = await client.GetAsync(relativeUrl);
  36. }
  37. }
  38.  
  39. private static HttpClient CreateHttpClient(string token)
  40. {
  41.  
  42.  
  43. var client = new HttpClient();
  44.  
  45. client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
  46. return client;
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement