IdentityServer4 has documentation with "Sign-in with External Identity Providers"
http://docs.identityserver.io/en/latest/topics/signin_external_providers.html#state-url-length-and-isecuredataformat
Unfortunately it is not complete but this is what I did:
Startup.cs
for .NET 5, Program.cs
for .NET 6:
services.AddAuthentication()
.AddOpenIdConnect("aad", "Azure AD", options =>
{
options.ClientSecret = "<ClientSecret>";
options.ResponseType = OpenIdConnectResponseType.Code;
options.ClientId ="<ClientId>";
options.Authority = "https://login.microsoftonline.com/<TenantId>/";
options.CallbackPath = "/signin-oidc";
})
.AddIdentityServerJwt();
You will then see an external login under "Use another service to log in.":

When completing login you should see this message.

Default settings got stuck after clicking on Register
. It was due to the new email not being confirmed. This could be solved with setting SignIn.RequireConfirmedAccount = false
services.AddDefaultIdentity<ApplicationUser>(options =>
options.SignIn.RequireConfirmedAccount = true)
You could also use "Resend email confirmation" or set EmailConfirmed
to true in [dbo].[AspNetUsers]
for the new user.
Azure AD settings. You will also need to add a client secret under Certificates & secrets
.

