Example #1
0
 public AppAuthApiService(AuthClientConfig authConfig, IAppAuthClient client, EncryptionSettingsModel encryptionSettings, ILogger <AppAuthApiService> logger)
 {
     _logger            = logger;
     _encryptionService = new EncryptionService(encryptionSettings);
     _client            = client;
     _authConfig        = authConfig;
 }
        public AppAuthClient(AuthClientConfig appAuthConfig, ILogger <Startup> logger)
        {
            _client = new HttpClient();
            _logger = logger;
            _logger.LogInformation($"App Auth API Config Values:{Environment.NewLine}{appAuthConfig.ToString()}");
            _client.BaseAddress = new Uri(appAuthConfig.BaseAddress);

            if (appAuthConfig.HeaderDefinitions != null)
            {
                foreach (KeyValuePair <string, string> h in appAuthConfig.HeaderDefinitions)
                {
                    _client.DefaultRequestHeaders.Add(h.Key, h.Value);
                }
            }

            _client.DefaultRequestHeaders.TransferEncodingChunked = false;
            //Default to application/json if no header type is specified
            if (_client.DefaultRequestHeaders.Accept.Count == 0)
            {
                _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            }
        }