Search code examples
javascriptfacebooknode.jsexpressfacebook-node-sdk

facebook-node-sdk for node.js scope parameter?


https://github.com/amachang/facebook-node-sdk decided to use this module to build my facebook integrated login for node.js following the example with express:

var express = require('express');

var Facebook = require('facebook-node-sdk');

var app = express.createServer();
app.configure(function () {
  app.use(express.bodyParser());
  app.use(express.cookieParser());
  app.use(express.session({ secret: 'foo bar' }));
  app.use(Facebook.middleware({ appId: 'YOUR_APP_ID', secret: 'YOUR_APP_SECRET' }));
});

app.get('/', Facebook.loginRequired(), function (req, res) {
  req.facebook.api('/me', function(err, user) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello, ' + user.name + '!');
  });
});

how to add additional permissions like "email"?


Solution

  • Take a look at the method getLoginUrl in the Facebook Node SDK. You can provide a scope parameter here to specify the email permission. See Permissions for a list of available permissions.