How can i fetch more user data on GET /userinfo

Hello everyone.
I’m trying to get user info with the access token via GET /userinfo
But i’m only given the info provided by openid email profile scope.
Can i get additional user info (like metadata and etc.) without using Management API?

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

Hi @BaikovOD

You are on the right track in trying to avoid Management API requests for regular authentication flows (as the rate limits for Management API are much stricter than limits for the Authentication API).

The best option would be to add any required information as a custom claim, either in the access token or in the ID token (depending on your needs).

E.g.

exports.onExecutePostLogin = async (event, api) => {
  // adds a custom claim only if the user has app_metadata.favorite_color
  const favoriteColor = event.user.app_metadata["favorite_color"];
  if (favoriteColor) {
    api.idToken.setCustomClaim("favorite_color", favoriteColor);
  }  
};

You can add additional logic to the action, for example only add the claim for a specific application (by checking the event.client.client_id or event.client.name).

More information at Create Custom Claims