.NET › Authentication & Authorization (Identity, JWT, OAuth)
How do you integrate external identity providers (Google, Microsoft Entra ID, Facebook) using OAuth/OpenID Connect in ASP.NET Core?
AdvancedAnswer
ASP.NET Core provides dedicated authentication handler packages (Microsoft.AspNetCore.Authentication.Google, .MicrosoftAccount, etc., or the generic OpenID Connect handler for any compliant provider) that implement the OAuth/OIDC redirect flow, handle token exchange, and map the provider's returned claims into a local ClaimsPrincipal -- letting users 'Sign in with Google' without the application ever handling their Google password directly.
builder.Services.AddAuthentication()
.AddGoogle(options => {
options.ClientId = builder.Configuration["Google:ClientId"];
options.ClientSecret = builder.Configuration["Google:ClientSecret"];
});
// Triggering the flow:
// GET /Account/ExternalLogin?provider=GoogleReal-world example A B2B SaaS platform lets enterprise customers sign in with Microsoft Entra ID (formerly Azure AD) using the OpenID Connect handler, integrating with each customer's existing corporate identity system instead of maintaining separate app-specific passwords.