Im trying to get AspNet Identity and EntraID(AzureAD) to work together in my Blazor .net 8 project. In my Programs.cs i have this
builder.Services.AddAuthorization();builder.Services.AddAuthentication("MyCookie") .AddCookie("MyCookie").AddMicrosoftAccount(options =>{ builder.Configuration.GetSection("Authentication:Microsoft").Bind(options);});builder.Services.AddIdentity<ApplicationUser, ApplicationRole>() .AddEntityFrameworkStores<ApplicationDbContext>() .AddRoleManager<RoleManager<ApplicationRole>>() .AddDefaultTokenProviders();and have this controller for external logins
public static IEndpointRouteBuilder MapIdentityEndpoints(this IEndpointRouteBuilder endpoints) { ArgumentNullException.ThrowIfNull(endpoints); var accountGroup = endpoints.MapGroup("/AccountExternal"); #region Microsoft Login accountGroup.MapGet("/PerformMicrosoftLogin", () => TypedResults.LocalRedirect($"/")); accountGroup.MapPost("/PerformMicrosoftLogin", async ( HttpContext context, [FromForm] string returnUrl ) => { string provider = "Microsoft"; var properties = new AuthenticationProperties { RedirectUri = returnUrl }; await context.SignOutAsync(); return TypedResults.Challenge(properties, [provider]); }); #endregion return accountGroup; }If i comment this part
builder.Services.AddIdentity<ApplicationUser, ApplicationRole>().AddEntityFrameworkStores<ApplicationDbContext>().AddRoleManager<RoleManager<ApplicationRole>>().AddDefaultTokenProviders();I can auth via Microsoft. But if I uncomment it and try signing in via Microsoft, it takes me through all the verification steps but will not authorize me. Just sends me back to the login page.