public async Task <User> GetAsync(string username, GetUserOptions options) { var uri = GetUserManagementUri(options.AuthenticationDomain, username); Logger.LogInformation($"Attempting to get user with username {username} - {uri}"); try { // check user exists before trying to read content var result = await _client.GetAsync(uri, options.CancellationToken).ConfigureAwait(false); if (result.StatusCode == HttpStatusCode.NotFound) { throw new UserNotFoundException(username); } result.EnsureSuccessStatusCode(); var json = await result.Content.ReadAsStringAsync().ConfigureAwait(false); return(JsonConvert.DeserializeObject <User>(json)); } catch (Exception exception) { Logger.LogError(exception, $"Error trying to get user with username {username} - {uri}"); throw; } }
public static Task <User> GetAsync(this IUserManager userManager, string username, Action <GetUserOptions> configureOptions) { var options = new GetUserOptions(); configureOptions(options); return(userManager.GetAsync(username, options)); }