My code works with this function:
// Function to retrieve the Guardians Enrollments (MFA)
function getMFAEnrollments(auth0Client, auth0UserId) {
return new Promise((resolve, reject) => {
auth0Client.getGuardianEnrollments({ id: auth0UserId }).then((enrollments) => {
resolve(enrollments);
}).catch((err) => {
const errMFA = {
code: 'scim_error_MFA_getGuardianEnrollments',
message: 'Error: Unable to retrieve the enrollments!',
details: err
};
reject(errMFA);
});
});
}
But when I tried with another function from the same class (that seems to work the same way see auth0 docs), my request returns an error: "auth0Client.getUserBlocks is not a function"
// Function to retrieve the User's Blocks (brute-force)
function getBlocksById(auth0Client, auth0UserId) {
return new Promise((resolve, reject) => {
auth0Client.getUserBlocks({ id: auth0UserId }).then((blocks) => {
resolve(blocks);
}).catch((err) => {
const errBlocks = {
code: 'scim_error_Blocks_getUserBlocks',
message: 'Error: Unable to retrieve blocks!',
details: err
};
reject(errBlocks);
});
});
}
Anybody knows why this is happening? Thanks
CodePudding user response:
By your docs that you leaved with link, I think there would be problem depend on your application design structures
getGuardianEnrollments is belong to UserManager (provides methods for getting user information and impersonating users) and getUserBlocks is belong to ManagementClient. It seems to be ManagementCLient and UserManager are seperate modules or classes of your app. To call getUserBlocks function just pass ManagementCLient instances to getBlocksById() function
CodePudding user response:
It appears that the error is occurring because the getUserBlocks function is not a part of the Auth0 ManagementClient class. Based on the Auth0 documentation, it seems that the ManagementClient class only has the getGuardianEnrollments method and not the getUserBlocks method. You should check the documentation to see if there is another method that can be used to retrieve the user's blocks or if there is a different class that needs to be used for that purpose.