async Task <List <PetData> > IAglCoreSvc.GetPets() { var url = _urls.PetsMicroservice + UrlsConfig.PetsOperations.Get(); //call identity server to get the token var TokenObj = await _IdentityServer.GetToken(); //set bearer _httpClient.SetBearerToken(TokenObj.Access_Token); var response = await _httpClient.GetAsync(url); response.EnsureSuccessStatusCode(); var catsResponse = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <List <PetData> >(catsResponse)); }
public async Task <ActionResult <Token> > Get() { try { var cats = await _svc.GetToken(); if (cats == null) { return(Unauthorized()); } else { return(Ok(cats)); } } catch (AggregateException) { return(BadRequest()); } }