How can we merge family_name and given_name attributes to make the name attribute?


We are using the update-profile-website (GitHub - ashishdasnurkar/update-profile-website: a simple node app that implements progressive profiling) from @ashish to get user attributes when our users log in. Is there a way to merge the family_name and given_name attributes collected from this app to form the name attribute?

Thanks in advance for your assistance.

Hey there @lwintour !

You can certainly combine those attributes into a single name attribute by setting a custom claim with an Action as name is not a restricted claim:

exports.onExecutePostLogin = async (event, api) => {
    if (event.authorization) {
       api.idToken.setCustomClaim("name", `${event.user.given_name} ${event.user.family_name}`);
       api.accessToken.setCustomClaim("name", `${event.user.given_name} ${event.user.family_name}`);

That should do the trick!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.