private HttpClientServiceFactory() { //no configuration for Dektop _configuration = null; var identityServerHttpClient = new HttpClient(); _coreHttpClient = new CoreHttpClient( new HttpClient() ); _tokenResponseService = new IdentityServerService( new IdentityServerHttpClientSelector( new List <IIdentityServerHttpClient> { { new ClientCredentialsHttpClient(identityServerHttpClient) }, { new PasswordHttpClient(identityServerHttpClient) } } ), new TokenResponseCacheManager( new MemoryCache( Options.Create( new MemoryCacheOptions() ) ) ) ); _requestMessageFactory = new HttpRequestMessageFactoryDesktop(); }
/// <summary> /// Constructor of the <see cref="HttpClientServiceFactory" />. /// </summary> /// <param name="configuration">Application configuration properties.</param> /// <param name="coreHttpClient">An <see cref="ICoreHttpClient"/> implementation that will execute the HTTP requests.</param> /// <param name="requestMessageFactory">The <see cref="IHttpRequestMessageFactory"/> to get a new <see cref="HttpRequestMessage"/>.</param> /// <param name="tokenResponseService">The <see cref="IIdentityServerService"/> to retrieve a token, if required.</param> public HttpClientServiceFactory(IConfiguration configuration, ICoreHttpClient coreHttpClient, IHttpRequestMessageFactory requestMessageFactory, IIdentityServerService tokenResponseService) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (coreHttpClient == null) { throw new ArgumentNullException(nameof(coreHttpClient)); } if (requestMessageFactory == null) { throw new ArgumentNullException(nameof(requestMessageFactory)); } if (tokenResponseService == null) { throw new ArgumentNullException(nameof(tokenResponseService)); } _configuration = configuration; _coreHttpClient = coreHttpClient; _tokenResponseService = tokenResponseService; _requestMessageFactory = requestMessageFactory; }
internal HttpClientService(ICoreHttpClient coreHttpClient, IHttpRequestMessageFactory requestMessageFactory, IIdentityServerService accessTokenService) { _coreHttpClient = coreHttpClient; _requestMessageFactory = requestMessageFactory; _accessTokenService = accessTokenService; Headers = new HttpClientServiceHeaders(); }