diff --git a/src/Microsoft.Identity.Web/WebAppExtensions/MicrosoftIdentityWebAppAuthenticationBuilder.cs b/src/Microsoft.Identity.Web/WebAppExtensions/MicrosoftIdentityWebAppAuthenticationBuilder.cs index 390d3c083..9ff6a56d4 100644 --- a/src/Microsoft.Identity.Web/WebAppExtensions/MicrosoftIdentityWebAppAuthenticationBuilder.cs +++ b/src/Microsoft.Identity.Web/WebAppExtensions/MicrosoftIdentityWebAppAuthenticationBuilder.cs @@ -165,7 +165,8 @@ internal static void WebAppCallsWebApiImplementation( }; // Handling the token validated to get the client_info for cases where tenantId is not present (example: B2C) - options.Events.OnTokenValidated += async context => + var onTokenValidatedHandler = options.Events.OnTokenValidated; + options.Events.OnTokenValidated = async context => { string? clientInfo = context!.ProtocolMessage?.GetParameter(ClaimConstants.ClientInfo); @@ -179,7 +180,7 @@ internal static void WebAppCallsWebApiImplementation( context!.Principal!.Identities.FirstOrDefault()?.AddClaim(new Claim(ClaimConstants.UniqueObjectIdentifier, clientInfoFromServer.UniqueObjectIdentifier)); } } - await Task.CompletedTask; + await onTokenValidatedHandler(context).ConfigureAwait(false); }; // Handling the sign-out: removing the account from MSAL.NET cache