How to call a ReST endpoint from inside the oauth-sso plugin?
-
Once i get the ID from oAuthPlugin , i need to call an external URL to get additional profile attributes. so was trying somthing simple like this but its complaining on including the Ajax package. Is there any Utilities in NodeBB i could use for calls like this? Is it better to use the request library in nodebb to achieve this?
function getProfile() {
var url = 'https://www.example.com/jsp/getJsonProfile.jsp?iruserid=' + username
$.getJSON( url, {})
.done(function( data ) {
var myJSON = JSON.stringify(data);
console.log ("json" + myJSON);
if ( (typeof(data.displayname) !== "undefined")) {
console.log ("user is logged :" + data.displayname);
} else {
console.log ("user is not logged");
}
})
.fail(function() {
console.log( "error retrieving idaas user status" );
});
}; -
You want to use the request module server-side. Look it up