User Roles in Session Object

Hello,
I have tried to add the exact code from the documentation, and it does not work

exports.onExecutePostLogin = async (event, api) => {
  const namespace = "https://auth.myapp.local";

  if (event.authorization && event.authorization.roles) {
    api.idToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
    api.accessToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
  }
};