None of the functions on existing blog posts work:
TypeError: management.roles.assignUsers is not a function
TypeError: management.users.assignRoles is not a function
TypeError: management.users.assignRolesToUser is not a function
How can I get this to work?
this is my current action:
exports.onExecutePostLogin = async (event, api) => {
// only run on first login
if (event.stats.logins_count !== 1) {
return;
}
const { ManagementClient } = require(“auth0”);
const management = new ManagementClient({
domain: event.secrets.AUTH0_DOMAIN,
clientId: event.secrets.M2M_CLIENT_ID,
clientSecret: event.secrets.M2M_CLIENT_SECRET,
});
try {
await management.roles.assignUsers(
{ id: event.secrets.USER_ROLE_ID },
{
users: \[event.user.user_id\],
}
);
} catch (e) {
console.log("Error assigning role:", e);
}
};