Reputation: 15
I have a ready-made project, and in it, when connecting authentication via Google, the connection does not work. All the standard settings described in the example. But if I create a new project, then everything works for me. What could be the problem? I can provide the necessary code
UPD
AccountController.cs
public async Task<IActionResult> SignIn(string provider)
{
return Challenge(new AuthenticationProperties { RedirectUri = "/Register" }, provider);
}
And Startup.cs
services.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddCookie(options =>
{
options.LoginPath = "/signin";
options.LogoutPath = "/signout";
})
.AddGoogle(options =>
{
options.ClientId = "myId";
options.ClientSecret = "MySecret";
});
I found a problem, if you finish this code then authorization does not occur
services.AddDbContext<MainContext>(options =>
options.UseSqlServer(_configuration.GetConnectionString("MainConnection")),
ServiceLifetime.Transient);
services.AddIdentity<User, Role>()
.AddEntityFrameworkStores<MainContext>()
.AddDefaultTokenProviders();
Upvotes: 0
Views: 67