I want to trigger MFA enrollment email programmatically.
working able to do it using the API
not working: unable to do it using Auth0 package as per ManagementClient - Documentation
Please note that the issue is with createGuardianEnrollmentTicket
only… looked at this hint but that didn’t work either
I am able to trigger other actions via Management API (both API & Auth0 package) like getGuardianEnrollments
or sendEmailVerification
etc.
Hi @akberiqbal,
Can you please share a code snippet of the call you are trying to make?
After a lot of permutation/combinations, found a working solution…
const createGuardianEnrollmentTicketForUser = async (userId) => {
const ManagementClient = require('auth0@2.27.0').ManagementClient;
const managementClient = new ManagementClient({
domain: 'MY_DOMAIN',
clientId: "MY_CLIENT_ID",
clientSecret: "MY_CLIENT_ID",
scope: 'read:users update:users create:guardian_enrollment_tickets'
});
return new Promise(async (resolve, reject) => {
if (managementClient && userId) {
try {
await managementClient.createGuardianEnrollmentTicket(
{
"user_id": userId,
"send_mail": true
},
function (err, ticket) {
if (err) {
reject(err);
}
resolve(ticket);
}
);
} catch (exp) {
console.log('createGuardianEnrollmentTicketForUser exp:', exp);
resolve([]);
}
} else {
resolve([]);
}
});
};
Hope the Auth0 people can update the official documentation with the following items:
- body is required for this function, e.g.
{ "user_id": userId, "send_mail": true }
- auth0@2.27.0 works
Thanks
1 Like
Thanks for sharing your solution.
1 Like