public static IServiceCollection AddPingOneManagement( this IServiceCollection services, PingOneConfigurationManagement configuration) { if (services == null) { throw new ArgumentNullException(nameof(services)); } PingOneConfigurationValidator.ValidateManagementConfiguration(configuration); services.AddSingleton(configuration); services.AddSingleton <IMemoryCache, MemoryCache>(); services.AddHttpClient <IPingOneTokenProvider, PingOneTokenProvider>( nameof(IPingOneTokenProvider), client => { client.BaseAddress = new Uri($"{configuration.AuthBaseUrl}/{configuration.EnvironmentId}/as/"); }); services.AddHttpClient <IManagementApiClient, ManagementApiClient>( nameof(IManagementApiClient), client => { client.BaseAddress = new Uri($"{configuration.ApiBaseUrl}/v1/environments/{configuration.EnvironmentId}/"); }) .AddHttpMessageHandler <PingOneApiAuthorizationHeaderHandler>(); services.AddTransient <PingOneApiAuthorizationHeaderHandler>(); return(services); }
public PingOneApiAuthorizationHeaderHandler( IPingOneTokenProvider pingOneTokenProvider, PingOneConfigurationManagement configuration, IMemoryCache cache) { _pingOneTokenProvider = pingOneTokenProvider; _configuration = configuration; _cache = cache; }