Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
621 views
in Technique[技术] by (71.8m points)

Azure AD B2C - get Custom attributes sets by Graph API in the token

After users has done the sign up I want to set some information and receive it in the token when they sign in.

In order to do that I am using custom attributes and setting the value using GraphAPI.

The way I add the custom attributes is as described here:

  1. In your Azure AD B2C tenant, select User flows.
  2. Select your policy (for example, "B2C_1_SignupSignin") to open it.
  3. Select User attributes and then select the custom attribute (for example, "ShoeSize"). Click Save.
  4. Select Application claims and then select the custom attribute.
  5. Click Save.

Those attributes should not be a concern of the user so I am not doing the step number 3 and here is where the problem comes.

I am able to set/get the value of the custom attribute using Graph API but the attribute is not present in the token. If I do the step number 3 then the custom attribute appears in the token.

Is there any workaround to achieve having the custom attributes in the token without having them in the sign up screen?

The link above also says:

The custom attribute is now available in the list of User attributes and for use in your user flows. A custom attribute is only created the first time it is used in any user flow, and not when you add it to the list of User attributes.

Which I believe is the reason why I can't see the attribute in the token, but I though that after setting it with GraphAPI and being able to read it, it would be in the token.

question from:https://stackoverflow.com/questions/66048741/azure-ad-b2c-get-custom-attributes-sets-by-graph-api-in-the-token

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It's not true.

Based on my test, if we don't do the step number 3 but do the step number 4, the custom attribute won't appear in sign up page but still can be included in the token.

Please make sure that you have updated the custom attribute for the signed-in user and use the same user to sign in with that user flow where you didn't do the step number 3 but did the step number 4.

Kindly check it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...