private void SetAuthenticationHeaders() { if (!string.IsNullOrEmpty(ClientConfiguration.Username) && !string.IsNullOrEmpty(ClientConfiguration.Password)) { var credentials = new HttpBasicAuthCredentials(ClientConfiguration.Username, ClientConfiguration.Password); _httpClient.AddHeader("Authorize", "Basic " + credentials); _httpClient.AddHeader("Authorization", "Basic " + credentials); } }
public void VisitClient(IHttpClient client) { foreach (var item in Headers) { client.AddHeader(item.Key, item.Value); } }
public ApiClient(IHttpClient httpClient, ISecretKeyProvider secretKeyProvider, IFileExtensionToMimeMapper fileExtensionToMimeMapper) { var secretKey = secretKeyProvider.GetSecretKey(); var tokenBytes = Encoding.UTF8.GetBytes(secretKey + ":"); _privateAuthToken = Convert.ToBase64String(tokenBytes); _fileExtensionToMimeMapper = fileExtensionToMimeMapper; _client = httpClient; _client.SetAuthorizationHeader(new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", _privateAuthToken)); _client.AddHeader("User-Agent", string.Format("SecurionPay-DOTNET/{0}", _version)); }
public MikiApiClient(string token) { client = new HttpClient(BaseUrl); client.AddHeader("Authorization", "Bearer " + token); }
public static void AddAuthorizationHeader(this IHttpClient client, string value) { client.RemoveHeader("Authorization"); client.AddHeader("Authorization", value); }