internal async Task <T> UpdateProviderConfigAsync(
            ApiClient client, AuthProviderConfigArgs <T> args, CancellationToken cancellationToken)
        {
            var providerId = this.ValidateProviderId(args.ProviderId);
            var content    = args.ToUpdateRequest();
            var updateMask = HttpUtils.CreateUpdateMask(content);

            if (updateMask.Count == 0)
            {
                throw new ArgumentException("At least one field must be specified for update.");
            }

            var query = new Dictionary <string, object>()
            {
                { "updateMask", string.Join(",", updateMask) },
            };
            var request = new HttpRequestMessage()
            {
                Method     = HttpUtils.Patch,
                RequestUri = BuildUri($"{this.ResourcePath}/{providerId}", query),
                Content    = NewtonsoftJsonSerializer.Instance.CreateJsonHttpContent(content),
            };

            return(await this.SendAndDeserializeAsync(client, request, cancellationToken)
                   .ConfigureAwait(false));
        }
        internal async Task <T> CreateProviderConfigAsync <T>(
            AuthProviderConfigArgs <T> args, CancellationToken cancellationToken)
            where T : AuthProviderConfig
        {
            var client = args.ThrowIfNull(nameof(args)).GetClient();

            return(await client.CreateProviderConfigAsync(this.apiClient, args, cancellationToken)
                   .ConfigureAwait(false));
        }
        internal async Task <T> CreateProviderConfigAsync(
            ApiClient client, AuthProviderConfigArgs <T> args, CancellationToken cancellationToken)
        {
            var query = new Dictionary <string, object>()
            {
                { this.ProviderIdParam, this.ValidateProviderId(args.ProviderId) },
            };
            var request = new HttpRequestMessage()
            {
                Method     = HttpMethod.Post,
                RequestUri = BuildUri(this.ResourcePath, query),
                Content    = NewtonsoftJsonSerializer.Instance.CreateJsonHttpContent(
                    args.ToCreateRequest()),
            };

            return(await this.SendAndDeserializeAsync(client, request, cancellationToken)
                   .ConfigureAwait(false));
        }