Warning during login : "assigning context.idToken.user_id is not supported"

As I monitor user logs, a warning during login catches my attention. The warning states:“assigning context.idToken.user_id is not supported, use Account Linking feature or namespaced id token claims”. I’m having difficulty identifying the root cause of the issue. Please note that I haven’t implemented any rules or hooks.

Hi @datamatica.in,

The warning you’re experiencing indicates that a Rule you have enabled is assigning a value to context.idToken.user_id, which is not a supported action. I recommend checking your Rule pipeline to identify the rule responsible for this behavior.

If you intend to assign the user_id to the ID token, we recommend setting it as a namespaced custom claim using an Action. Here’s an example:

exports.onExecutePostLogin = async (event, api) => {
  const namespace = 'https://myapp.example.com';
  if (event.authorization) {
    // Set claims in ID token
    api.idToken.setCustomClaim(`${namespace}/user_id`, event.user.user_id);
  }
};

Let me know if you have any questions.

Thanks,
Rueben

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