简体   繁体   中英

Error in Auth0 ManagementClient function getUserBlocks

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM