I have a Blazor WASM application.
I am getting the id token and putting it in the header for a http api call to aws apigateway v2 http api.
In a controller method, I am spilling info to the log.
Tim, did you ever solve this? We’re facing this same issue (blazor wasm, self hosted, client can get okta auth from @context fine but server’s User.Identity.Name is empty).
Hey @reuben.ahmed, this is an ASP.NET Core issue that has historical reasons.
The native JWT handler expects the OpenID Connect claim type name to be http://schemas.microsoft.com/ws/2008/06/identity/claims/name. So, you need to map the expected claim to the actual claim as follows:
var oidcOptions = new OpenIdConnectOptions
{
TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = "name"
}
};
This applies to the role claim as well.
If you want to learn more about the historical reasons, read this article.