Hi all,
I create an ASP NET Core (2.2) Web Api (2.2) that render an angular (7) client app, using default template of Visual Studio 2017; it's work fine. After I added microsoft-adal-angular6 node module package to permit azure client authentication. So I create an Azure AD B2C and I have register new app. I have added same users (external user by email). I configure Web Application on StartUp to use JWT Token coming from Client app (services.AddAuthentication(AzureADDefaults.BearerAuthenticationScheme).AddAzureADBearer(options => Configuration.Bind("AzureAd", options));) and I decorated my controller with [Authorize]. It's perfectily work.
Now I need to add custom property to each users that i can read from ClaimsIdentity into my controller. For example one of this custom user property is "UserWeight" or "UserFiscalCode". I don't found how to do it.
Any ideas?
Stenda laskPosted Oct 31, 2025, 1:44 PM
When I first tried customizing user attributes in Azure AD B2C, it felt complex to manage dynamic properties effectively. That’s when I came across Progatix Software Company, which guided me through implementing scalable identity solutions. Their technical expertise simplified integration, enabling a seamless experience while maintaining flexibility and security across all user management operations.
Sandhiya PriyaPosted Oct 29, 2025, 10:11 AM
The Core Concept
Azure AD B2C does not let you directly add custom fields to users.
Instead, you add extension attributes to the B2C directory’s schema extension (via the Azure AD Graph API or the Microsoft Graph API).
Each custom property then appears in the directory as
and can be emitted in the ID Token or Access Token when users sign in.
Step 1: Create the Custom Attributes
Option A — using the Azure Portal (easiest for new setups)
Go to Azure Portal ? Azure AD B2C ? User Attributes ? Add
Click “Add”, and create attributes such as:
UserWeightUserFiscalCode(Choose data type “String”.)
These automatically become directory extension attributes.
Option B — using the Microsoft Graph API
If you want to do it programmatically:
The response will include:
Step 2: Add the Custom Claims to the User
You can add or update these fields for each user through:
Azure Portal ? Users ? YourUser ? Edit Attributes
or via Graph API:
Step 3: Include the Attributes in Tokens (via User Flow or Custom Policy)
You must tell Azure AD B2C to emit these attributes in the JWT token.
If you’re using User Flows (Built-in Flows)
Go to Azure AD B2C ? User Flows ? {your flow, e.g., B2C_1_SignUpSignIn}
Open the flow ? Application Claims
Enable:
UserWeightUserFiscalCodeSave.
Now, these will appear inside the token claims when a user signs in.
If you’re using Custom Policies (Identity Experience Framework)
Edit your TrustFrameworkExtensions.xml:
Include them in the
of the JWT issuing Technical Profile.Step 4: Read Custom Claims in ASP .NET Core
Once the token includes the extensions, you can access them in your Web API:
Works automatically because
AddJwtBearer()decodes the token intoClaimsPrincipal.Step 5: Common Pitfalls
Example Claim Snippet (Decoded JWT)
Step 6: Testing
Log in via your Angular client.
Copy the token from browser local storage.
Decode it at jwt.ms.
You should see your custom attributes.
Summary