/// <summary> /// Repository for interacting with <see cref="StorageContainer"/> within the Comic Engine Comic API /// </summary> /// <param name="config"><see cref="StorageContainerHttpRepository"/> pulled from the appsettings.</param> /// <param name="httpContextAccessor"></param> /// <param name="tokenClientSettings"></param> public StorageContainerHttpRepository( ComicEngineApiConfiguration config, IHttpContextAccessor httpContextAccessor, TokenClientSettings tokenClientSettings) { _comicApiConfig = config; _httpContextAccessor = httpContextAccessor; _tokenClientSettings = tokenClientSettings; }
internal TokenClient(TokenClientSettings settings) { _clientSettings = settings ?? throw new ArgumentException("TokenClient settings must be provided."); if (string.IsNullOrWhiteSpace(_clientSettings.ClientId) || string.IsNullOrWhiteSpace(_clientSettings.ClientSecret)) { throw new ArgumentException("Client ID and Client Secret must be provided."); } if (string.IsNullOrWhiteSpace(_clientSettings.Scope)) { throw new ArgumentException("Scope must be provided."); } if (string.IsNullOrWhiteSpace(_clientSettings.Region)) { throw new ArgumentException("Region must be provided."); } _http = new HttpClient(); _http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue( "Basic", Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes($"{_clientSettings.ClientId}:{_clientSettings.ClientSecret}"))); }