Но когда я попробуйте добавить его в сервисы, сайт останавливается с сообщением
Программа «[20972] LT.LoveMatch.Natural.exe» завершила работу с кодом
3221225477 (0xc0000005) «Нарушение прав доступа».
Код:
Код: Выделить всё
GoogleConfigSection config = new GoogleConfigSection();
builder.Configuration.GetSection("Google").Bind(config);
builder.Services.AddAuthentication().AddGoogle(opt =>
{
opt.ClientId = config.ClientId;
opt.ClientSecret = config.ClientSecret;
});
Код: Выделить всё
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
builder.Services.AddAuthentication().AddGoogle(opt => {
opt.ClientId = "clientId";
opt.ClientSecret = "secret";
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();
Подробнее здесь: https://stackoverflow.com/questions/777 ... entication