Search code examples
azure-active-directoryazure-ad-b2cpolicy

Azure B2C External provider with custom claims and policies


I have an Azure B2C tenant with some identity providers (Facebook, LinkedIn, etc) and a custom claim where the user is able to choose a gender.

During the sing up with one of those, I'm able to get the gender's claim in the token, but this doesn't happen when the user signs in. I was wondering where is the right place to map/include this custom claim since I've been using the base custom policies: SocialAndLocalAccount

Any clue about where to get it? I have my custom claim inside the SelfAsserted-Social's Technical Profile but no luck during the sign in.


Solution

  • The SelfAsserted-Social technical profile will only be executed on the first time the user connects with his social account.

    As you can see from the comments in the user journey

    Show self-asserted page only if the directory does not have the user account already (i.e. we do not have an objectId).

    You need to persist that claim if you want to reuse it as per comment here

    If a claim is to be persisted in the directory after having been collected from the user, it needs to be added as a PersistedClaim in the ValidationTechnicalProfile referenced below

    You then need to read it from AD in your AAD-UserRead... technical profiles

    And output it in your Relaying Party's output claims.

    Follow this guide https://learn.microsoft.com/en-us/azure/active-directory-b2c/custom-policy-configure-user-input#add-a-claim-to-the-user-interface for the Social profiles where city in the examples is your gender claim.