Reputation: 21
I'm learning Blazor and trying to interact with Azure EntraID to protect some pages. At this point was able to achieve that.
My question is related to "@context.User.Identity?.Name"... As I'm connected to EntraID, some user details will be useful for some features, for example e-mail address. But I can't find anywhere to enable context to bring other values from EntraID instead just Name.
Please, how can I retrieve other user details to be part of my code on other pages? Anyone have a guide to achieve that?
Thanks!
Reviewed every file in the project to locate @context, but no success until now.
Upvotes: 2
Views: 94
Reputation: 8811
You could go to Azure EntraId - App Registrations - Your App - Manage - Token Configuration - Add optional claims. Add Email claim to IdToken for the user.
var email = User.Claims.FirstOrDefault(c => c.Type == "email")?.Value;
Upvotes: 1