public static Task UpsertAsync(this IUserManager userManager, string username, IEnumerable <UserRole> roles, Action <UpsertUserOptions> configureOptions)
        {
            var options = new UpsertUserOptions();

            configureOptions(options);

            return(userManager.UpsertAsync(username, roles, options));
        }
        public async Task UpsertAsync(string username, IEnumerable <UserRole> roles, UpsertUserOptions options)
        {
            var uri = GetUserManagementUri(options.AuthenticationDomain, username);

            Logger.LogInformation($"Attempting to create user with username {username} - {uri}");

            try
            {
                var content = new FormUrlEncodedContent(GetUserFormValues(options.Password, username, roles));
                var result  = await _client.PutAsync(uri, content, options.CancellationToken).ConfigureAwait(false);

                result.EnsureSuccessStatusCode();
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, $"Error trying to upsert user - {uri}");
                throw;
            }
        }