Skip to content

Instantly share code, notes, and snippets.

@aaguiarz
Created December 15, 2017 16:28
Show Gist options
  • Save aaguiarz/d54edf64b462d44555130c09bd01969c to your computer and use it in GitHub Desktop.
Save aaguiarz/d54edf64b462d44555130c09bd01969c to your computer and use it in GitHub Desktop.
Get Users using Management API with access_token
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