I am trying to set up a web app with authentication via a google API, using the docs from microsoft.
My ConfigureServices looks like this:
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>();
services.AddControllersWithViews();
services.AddRazorPages();
services.AddAuthentication().AddGoogle(options =>
{
IConfigurationSection googleAuthNSection =
Configuration.GetSection("Authentication:Google");
options.ClientId = googleAuthNSection["ClientId"];
options.ClientSecret = googleAuthNSection["ClientSecret"];
options.CallbackPath = "/oauth2callback";
});
services.AddTransient<IEmailSender, EmailSender>();
}
I have set up SendGrid to send mails for activating the accounts.
However, when I am registering an account with the google API, the confirmation mail is not sent, and I can't activate the account. This works just fine when I am registering an account with just an e-mail address.
The confirmation mail is sent when I set the SignIn.RequireConfirmedAccount to false. But why do I have to do this? It does not make sense to me that the confirmation mail is only being sent in case the account confirmation is not required. I also don't want to set this to false because otherwise you can log on without confirmation.
I am using .NET core 3.0