Esempio n. 1
0
        internal AuthenticationHeaderValue Create(RestClientDefaultSettings configuration)
        {
            var authentication = default(AuthenticationHeaderValue);

            if (!string.IsNullOrEmpty(configuration?.BasicCredentials) && string.IsNullOrEmpty(_credentials))
            {
                authentication = CreateBasic(configuration.BasicCredentials);
            }

            if (!string.IsNullOrEmpty(_credentials))
            {
                authentication = CreateBasic(_credentials);
            }

            if (!string.IsNullOrEmpty(configuration?.BearerToken) && string.IsNullOrEmpty(_bearerToken))
            {
                authentication = CreateBearer(configuration.BearerToken);
            }

            if (!string.IsNullOrEmpty(_bearerToken))
            {
                authentication = CreateBearer(_bearerToken);
            }

            return(authentication);
        }
Esempio n. 2
0
 private RestClient(RestClientDefaultSettings configuration) : this(configuration.HttpClient) => _configuration = configuration;