Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any Node.js client library to make OAuth and OAuth2 API calls to Twitter, Facebook, Google, LinkedIn, etc.?

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?

like image 884
pavanlimo Avatar asked Jan 15 '14 11:01

pavanlimo


People also ask

Which API creates client in node JS?

The Node. js Client uses the MarkLogic REST Client API to communicate with MarkLogic Server, so it uses the same security model.

What is OAuth2 Nodejs?

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.

Should I use OAuth2 for my API?

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.


2 Answers

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.

like image 72
Jared Hanson Avatar answered Oct 31 '22 04:10

Jared Hanson


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);
});
like image 44
Tmm Avatar answered Oct 31 '22 04:10

Tmm