Exemplo n.º 1
0
        protected async Task <HttpResponseMessage> SendAsync(HttpMethod method, string uri)
        {
            var accessToken = await authClient.RefreshAccessToken();

            var request = new HttpRequestMessage(method, uri);

            request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            request.Headers.Authorization =
                new AuthenticationHeaderValue("Bearer", accessToken);

            return(await httpClient.SendAsync(request));
        }
Exemplo n.º 2
0
        public async Task RefreashAccessTokenAndGetResource()
        {
            token = await authClient.RefreshAccessToken();

            Console.WriteLine($"Access token from refresh token\n{token}");

            resourceClient.DefaultRequestHeaders.Authorization =
                new AuthenticationHeaderValue("Bearer", token);

            var getResourceResponse = await resourceClient.GetAsync($"v3/company/{ResourceId}/companyinfo/{ResourceId}");

            Console.WriteLine(await getResourceResponse.Content.ReadAsStringAsync());

            var company = await getResourceResponse.Content.ReadAsAsync <dynamic>();

            ((string)company.CompanyInfo.CompanyName).Should().Be("Sandbox Company_US_1");
        }