ID Token for Open ID Connect


Is there a way to add given_name and family_name into the ID Token? A sample action maybe?

My third party platform requires these to auto generate users on authentication if they don’t exist, and they are missing in the ID Token. We only have name.

Hey @Kush1 !

Do user’s have a given_name and family_name in Auth0? If so, I believe these claims should be included in ID tokens by default if including the profile scope when calling the authorize endpoint.

If not, here’s a Post Login Action that should do the trick:

exports.onExecutePostLogin = async (event, api) => {
  const namespace = ''; // Replace with a unique identifier URL
  if (event.user.given_name) {
    api.idToken.setCustomClaim(`${namespace}given_name`, event.user.given_name);
  if (event.user.family_name) {
    api.idToken.setCustomClaim(`${namespace}family_name`, event.user.family_name);

1 Like

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