Ejemplo n.º 1
0
        public async Task <List <WizdomInstance> > GetInstancesAsync()
        {
            if (_wizdomInstances != null)
            {
                return(_wizdomInstances);
            }

            string token = await _tokenHandler?.GetTokenAsync(clientId);

            HttpClientHandler handler = new HttpClientHandler();

            handler.AllowAutoRedirect        = true;
            handler.MaxAutomaticRedirections = 10;
            var client = new HttpClient(handler);

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
            HttpResponseMessage response = await client.GetAsync(baseAddress + "/disco");

            if (response.IsSuccessStatusCode)
            {
                return(await DeserializeStreamAsync <List <WizdomInstance> >(response));
            }

            throw new ServerException("Error getting instances", await response.Content.ReadAsStringAsync(), response.StatusCode, response.Headers.ToString());
        }