• An authentication & authorization standard against third  party REST services• Set a list of permission to access data a...
Implementation example for Facebook
Implementation example for Facebook
• You don’t have to implement your own authentication    mechanism•   Save the security headache•   Save development time•...
everyauth  .facebook    .appId(conf.fb.appId)    .appSecret(conf.fb.appSecret)    .findOrCreateUser( function (session, ac...
https://graph.facebook.com/mike.shaver/picturehttps://graph.facebook.com/mike.shaver/picture{ "data": { "data":   {     "u...
var baseUrl = "https://graph.facebook.com/";var url = userId + "/likes";var params = {access_token: accessToken};request({...
var fbapi = require(facebook-api);var client = fbapi.user(user.accessToken);  client.me.friends(function (err, friends) { ...
https://github.com/orkaplan/social-demo
Node social
Node social
Node social
Node social
Node social
Node social
Node social
Node social
Node social
Upcoming SlideShare
Loading in …5
×

Node social

4,191 views

Published on

Social networks integration using node js:
1. OAuth2
2. API consumption
3. everyauth vs. passport.js

the demo code can be found under my github repo - https://github.com/orkaplan/social-demo

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,191
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
12
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Node social

  1. 1. • An authentication & authorization standard against third party REST services• Set a list of permission to access data and perform actions: • Read user data • Write to user data • Delete user data • Get user Location• At the end of the process an access_token is obtained
  2. 2. Implementation example for Facebook
  3. 3. Implementation example for Facebook
  4. 4. • You don’t have to implement your own authentication mechanism• Save the security headache• Save development time• Use OAuth for 3rd party services to provide the authentication mechanism for the product.• Get access token and use it to fetch basic details about the user.• Examples: • Asana leverages Google authentication in addition to its service. • For Android use Google ID (google play API). • Social plugins for Wordpress.
  5. 5. everyauth .facebook .appId(conf.fb.appId) .appSecret(conf.fb.appSecret) .findOrCreateUser( function (session, accessToken, accessTokenExtra,fbUserMetadata) { return this.promise(); var user = usersByFbId[fbUserMetadata.id] || (usersByFbId[fbUserMetadata.id] = addUser(facebook, fbUserMetadata)); promise.fulfill(user); }) .redirectPath(/);
  6. 6. https://graph.facebook.com/mike.shaver/picturehttps://graph.facebook.com/mike.shaver/picture{ "data": { "data": { "url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/372183_100002526091955_998385602_q.jpg", "url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/372183_100002526091955_998385602_q.jpg", "is_silhouette": false } "is_silhouette": false } }}
  7. 7. var baseUrl = "https://graph.facebook.com/";var url = userId + "/likes";var params = {access_token: accessToken};request({ method: GET, url:baseUrl + url, qs: params, json: true }, function (err, res, body) { if (err) return callback(err); if (!res || res.statusCode != 200) return callback({message: "invalidstatus code" + (res && res.statusCode) , body: body}); return callback(null, body); } );
  8. 8. var fbapi = require(facebook-api);var client = fbapi.user(user.accessToken); client.me.friends(function (err, friends) { res.render(account, { user: user, friends: friends}); });
  9. 9. https://github.com/orkaplan/social-demo

×