/// <summary> /// Initializes a new instance of the ContentDeliveryService class /// </summary> /// <param name="configuration">Reference to the <see cref="IPasswordBasedConfiguration"/></param> public ContentDeliveryService(IPasswordBasedConfiguration configuration) { var httpClient = new HttpClient(new AuthenticatedHttpClientHandler(configuration)) { BaseAddress = new Uri(Constants.Urls.BaseCdnUrl) }; Content = new ContentDelivery(configuration, httpClient); Media = new MediaDelivery(configuration, httpClient); }
/// <summary> /// Initializes a new instance of the ContentDeliveryService class /// </summary> /// <param name="configuration">Reference to the <see cref="IApiKeyBasedConfiguration"/></param> public ContentDeliveryService(IApiKeyBasedConfiguration configuration) { var httpClient = new HttpClient { BaseAddress = new Uri(Constants.Urls.BaseCdnUrl), DefaultRequestHeaders = { { Constants.Headers.ApiKey, configuration.Token } } }; Content = new ContentDelivery(configuration, httpClient); Media = new MediaDelivery(configuration, httpClient); }
/// <summary> /// Initializes a new instance of the ContentDeliveryService class /// </summary> /// <param name="configuration">Reference to the <see cref="IPasswordBasedConfiguration"/></param> public ContentDeliveryService(IPasswordBasedConfiguration configuration) { var authenticationService = new AuthenticationService(configuration); var tokenResolver = new UserPasswordAccessTokenResolver(configuration.Username, configuration.ProjectAlias, authenticationService); var httpClient = new HttpClient(new AuthenticatedHttpClientHandler(tokenResolver)) { BaseAddress = new Uri(Constants.Urls.BaseCdnUrl) }; Content = new ContentDelivery(configuration, httpClient); Media = new MediaDelivery(configuration, httpClient); }
/// <summary> /// Initializes a new instance of the ContentDeliveryService class /// </summary> /// <remarks> /// When passing in your own HttpClient you are responsible for setting the authentication headers /// </remarks> /// <param name="configuration">Reference to the <see cref="IHeadlessConfiguration"/></param> /// <param name="httpClient">Reference to the <see cref="HttpClient"/></param> public ContentDeliveryService(IHeadlessConfiguration configuration, HttpClient httpClient) { Content = new ContentDelivery(configuration, httpClient); Media = new MediaDelivery(configuration, httpClient); }