I am using Azure B2C in a ASP.NET Core 3 application, which is working perfectly. I use the following code in Startup:
services.AddAuthentication(AzureADB2CDefa
I found my answer, by searching for ["Events.OnTokenValidated" AzureAdB2C] in github, and assembled the following for my case:
// My existing code in Startup:
services.AddAuthentication(AzureADB2CDefaults.AuthenticationScheme)
.AddAzureADB2C(options => Configuration.Bind("AzureAdB2C", options));
// My added code to handle the OnTokenValidated event
services.Configure<OpenIdConnectOptions>(AzureADB2CDefaults.OpenIdScheme, options =>
{
var onTokenValidated = options.Events.OnTokenValidated;
options.Events.OnTokenValidated = context =>
{
onTokenValidated?.Invoke(context);
// My custom handler goes below: