// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Для пользователей services.AddDbContext <SqlDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("MainConnection"))); services.AddControllers().AddNewtonsoftJson(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "IdentityServer4_implementation", Version = "v1" }); }); services.AddIdentityServer(options => options.IssuerUri = "localhost") .AddInMemoryApiResources(ClientStore.GetApiResources()) .AddInMemoryApiScopes(ClientStore.GetApiScopes()) .AddInMemoryIdentityResources(ClientStore.GetIdentityResources()) .AddInMemoryClients(ClientStore.GetClients()) .AddProfileService <ProfileService>() //.AddTestUsers(Users.GetTestUsers()) .AddDeveloperSigningCredential(false); services.AddTransient <ITokenProvider, TokenProvider>(); services.AddScoped <IUserRepository, UserRepository>(); services.AddAuthentication() .AddGoogle("Google", options => { options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme; options.ClientId = "434483408261-55tc8n0cs4ff1fe21ea8df2o443v2iuc.apps.googleusercontent.com"; options.ClientSecret = "3gcoTrEDPPJ0ukn_aYYT6PWo"; options.CallbackPath = "/signin-google"; }); // Для пользователей services.AddTransient <IResourceOwnerPasswordValidator, ResourceOwnerPasswordValidator>(); services.AddTransient <IProfileService, ProfileService>(); }