Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net.Http;
- using System.Net.Http.Headers;
- using System.Text;
- using System.Threading.Tasks;
- using IdentityModel.Client;
- namespace ConsoleApp41
- {
- class Program
- {
- static void Main(string[] args)
- {
- Run().Wait();
- }
- public static async Task Run()
- {
- var baseUrl = "http://lab03-wa1:5204/";
- var api = "http://lab03-wa1/sso";
- var tokenClient = new TokenClient($"{api}/connect/token/", "public_api_intg", "10D41201-5DE0-45EA-B7C6-56205164836F");
- var cred = await tokenClient.RequestClientCredentialsAsync("reference_data data_service position_api");
- string companyCode = "";
- string userName = "";
- string accountCode = "";
- string currencyCode = "";
- DateTime executionDate = DateTime.Now;
- var relativeUrl = $"/v2/custodians";
- using (var client = CreateHttpClient(relativeUrl))
- {
- client.BaseAddress = new Uri(baseUrl);
- var result = await client.GetAsync(relativeUrl);
- }
- }
- private static HttpClient CreateHttpClient(string token)
- {
- var client = new HttpClient();
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- return client;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement