I did a lot of googling and the best I could find was: https://github.com/ciaranj/node-oauth
Are there any libraries on top of this, which provide wrappers to make API calls to Twitter, Facebook, Google, LinkedIn, etc. to say post a tweet or DM somebody or get friends list or post a link to Facebook/G+ et al.?
I'm aware of Passport.js, but its usage is limited to obtaining authentication and authorization from these social sites. Beyond that, currently we will have to individualize API calls via node-oauth to perform activities mentioned above.
Have I missed something? Are you aware of any such libraries?
The Node. js Client uses the MarkLogic REST Client API to communicate with MarkLogic Server, so it uses the same security model.
OAuth 2.0 is the industry-standard protocol for authorization, enabling third-party applications to obtain limited access to an HTTP service, either on behalf of a resource owner or by allowing the third-party application to obtain access on its own behalf.
You only really need OAuth2 and OpenID Connect if you'd like your users to give consent ("i.e. I want to allow this app access to my personal data"). You do not need OAuth2 to generate a JSON Web Token, a Personal Access Token, a Native Mobile App Session Token.
Once you have used Passport.js to obtain an access token, I recommend (and personally use) request to make all API calls to third-party services.
In my opinion, provider-specific wrappers just add unnecessary complication. Most RESTful APIs are very simple HTTP requests. Extra layers only get in the way and add bugs to track down. Further, by sticking with request
, you can integrate with any third party using the same, familiar module.
CloudRail might be a good alternative. It provides an abstracted API for most social networks and handles the authentication pretty well. Here is an example:
const services = require("cloudrail-si").services;
// let profile = new services.GooglePlus(redirectReceiver, "[clientIdentifier]", "[clientSecret]", "[redirectUri]", "[state]");
// let profile = new services.GitHub(redirectReceiver, "[clientIdentifier]", "[clientSecret]", "[redirectUri]", "[state]");
// let profile = new services.Slack(redirectReceiver, "[clientIdentifier]", "[clientSecret]", "[redirectUri]", "[state]");
// let profile = new services.Instagram(redirectReceiver, "[clientIdentifier]", "[clientSecret]", "[redirectUri]", "[state]");
// ...
let profile = new services.Facebook(redirectReceiver, "[clientIdentifier]", "[clientSecret]", "[redirectUri]", "[state]");
profile.getFullName((err, fullName) => {
if (err) throw err;
console.log("User's full name is " + fullName);
});
profile.getEmail((err, email) => {
if (err) throw err;
console.log("User's email address is " + email);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With