I have added a new custom attribute and selected it in the Application claims of the signup-signin userflow.
So I created a new user and set a value for this custom attribute during the signup. When I sign in with the user, the attribute is persisted in the token claims so I can get the value from the token.
So now I need to get it using Graph SDK, I am trying to do so using the following code which is inspired from this Microsoft Docs
ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication);
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
var customAttribute = $"extension_clientIdWithoutDash_CustomAttributeName";
var result = await graphClient.Users["2d7f1b9d-b57c-4a1a-bf56-fa27a952bacf"]
.Request()
.Select(customAttribute)
.GetAsync();
var customAttributsAreHere = result.AdditionalData;
But when I check the response the custom attribute is not there. Default attributes are there if I include them in the select. Any clue what may be the reason?
This is the Client Id I am using when requesting the custom attribute as "extension_clientId_customattribute". (but without the hyphens)
You must use client id of the application created with your extensions (depends on how extension was created). Please refer this article:
Extension attributes can only be registered on an application object, even though they might contain data for a user. The extension attribute is attached to the application called b2c-extensions-app. Do not modify this application, as it's used by Azure AD B2C for storing user data. You can find this application under Azure AD B2C, app registrations.
You can find this application in Azure AD -> App Registration.