Created
December 15, 2017 16:28
-
-
Save aaguiarz/d54edf64b462d44555130c09bd01969c to your computer and use it in GitHub Desktop.
Get Users using Management API with access_token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getUserUsingManagementApi() { | |
webAuth.checkSession( | |
{ | |
audience: "https://aaguiar0.auth0.com/api/v2/", | |
scope: 'read:current_user' | |
}, | |
function(err, result) { | |
if (!err) { | |
var auth0Manage = new auth0.Management({ | |
domain: AUTH0_DOMAIN, | |
token: result.accessToken | |
}); | |
auth0Manage.getUser(result.idTokenPayload.sub, function(err, userInfo) { | |
if (!err) { | |
// use userInfo | |
} | |
}); | |
} | |
else { | |
console.logt('Could not get an API Management token ' + | |
err.error_description | |
); | |
} | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment