/// <inheritdoc /> public async Task <IReadOnlyList <UserModel> > GetUsersWithClaim(string product, string claim) { // Validate parameters. if (string.IsNullOrEmpty(product)) { throw new ArgumentNullException(nameof(product)); } if (string.IsNullOrEmpty(claim)) { throw new ArgumentNullException(nameof(claim)); } // Validate user exists and is loaded. if (user == null || !user.IsLoaded) { throw new NotAuthorizedException($"Method {nameof(GetUsersWithClaim)} Requires a loaded {nameof(IdentityUser)}."); } // Get path name from app settings. var path = microservicesWrapper.GetPathByName(IdentityB2bClientName, "GetUsersWithClaim"); // Check if path exists, if not throw. if (string.IsNullOrEmpty(path)) { throw new ConfigurationErrorsException($"Microservice Configuration For {IdentityB2bClientName} not found or is invalid. Please ensure you have a valid configuration set in your appsettings for the IdentityB2B Microservice!"); } // Populate claim and product into path and create HttpReqeustMessage. var fullPath = string.Format(path, claim, product); var message = new HttpRequestMessage(HttpMethod.Get, fullPath); // Add Identity User headers needed in the Identity B2B Microservice query. var headers = user.ToDictionary(); foreach (var(key, value) in headers) { message.Headers.Add(key, value.ToString()); } // Send request and ensure it was a successful request. var response = await identityB2bHttpClient.SendAsync(message); response.EnsureSuccessStatusCode(); // Read response to List of UserModel and return. await using var responseStream = await response.Content.ReadAsStreamAsync(); using var streamReader = new StreamReader(responseStream); using var jsonTextReader = new JsonTextReader(streamReader); return(serializer.Deserialize <List <UserModel> >(jsonTextReader)); }