public void ConfigureServices(IServiceCollection services) { services.AddIdentityServer() .AddExtensionGrantValidator <SmsAuthCodeValidator>() .AddDeveloperSigningCredential() .AddInMemoryClients(IdentityConfig.GetClient()) .AddInMemoryIdentityResources(IdentityConfig.GetIdentityResources()) .AddInMemoryApiResources(IdentityConfig.GetResources()); services.AddSingleton(new HttpClient()); services.AddScoped <IAuthCodeService, AuthCodeService>() .AddScoped <IUserService, UserService>(); services.AddSingleton(typeof(ResilienceClientFactory), sp => { var logger = sp.GetRequiredService <ILogger <ResilienceClientFactory> >(); var httpContextAccessor = sp.GetRequiredService <IHttpContextAccessor>(); return(new ResilienceClientFactory(logger, httpContextAccessor, 5, 5)); }); services.AddSingleton <IHttpClient>(sp => { return(sp.GetRequiredService <ResilienceClientFactory>().GetResilienceHttpClient()); }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(p => { p.Filters.Add <ShawnExctption>(); }); services.AddIdentityServer() .AddExtensionGrantValidator <SmsAuthCode>() .AddDeveloperSigningCredential() .AddInMemoryClients(IdentityConfig.GetClients()) .AddInMemoryApiResources(IdentityConfig.GetApiResources()) .AddInMemoryIdentityResources(identityResources: IdentityConfig.GetIdentityResources()); services.AddTransient <HttpClientDelegate>(); services.AddLogging(); services.AddUserHttpClient(Configuration); services.AddTransient <IUserService, UserService>(); services.AddTransient <IAuthCodeService, AuthCodeService>(); }