0

I am trying to build a simple nodejs app that can log in with facebook using express and everyauth. Following the README tutorial here, I've performed the following setup in app.js:

var everyauth = require('everyauth');

everyauth.facebook
    .appId('829428097067274')
    .appSecret('2c4d4a96514aa8374fbc54d611945148')
    .findOrCreateUser(function (session, accessToken, accessTokExtra, fbUserMetadata) {
        // I will fill this in with something real later, but for now
        // I just want something that works with a fake session

        console.log("in find or create user")

        // this is always undefined...
        console.log(session);

        // these look good; I'm getting real user info
        console.log(accessToken);
        console.log(accessTokExtra);
        console.log(fbUserMetadata);

        // I'm not sure what I need to return here. I've tried
        // variations of this.Promise()/promise.fulfill() as well
        return { id: 100, session: "the session" };
    })
    .redirectPath('/');

// ...

// this gives an error saying that session is no longer
// bundled with express, but I'm not sure which package to replace
// it with:
// app.use(express.session());

app.use(everyauth.middleware(app));

When I launch my app, I visit localhost:3000/auth/facebook, which correctly redirects to facebook. I authorize the app there, which redirects me to localhost:3000/auth/facebook/callback. However, here my app logs an error of:

Step getSession offacebookis promising: session ; however, the step returns nothing. Fix the step by returning the expected values OR by returning a Promise that promises said values.

What am I doing wrong?

ChaseMedallion
  • 20,860
  • 17
  • 88
  • 152
  • Did you try enabling debugging as described on the project page: https://github.com/bnoguchi/everyauth#debugging---logging-module-steps – Matthew Bakaitis Jul 21 '14 at 10:52
  • Also, there is at least one facebook issue in the queue and another with express 4 compatibility...you might want to look at the issues queue. Everyauth has not been updated actively in a long time. You may want to investigate things like Passport or other alternatives. – Matthew Bakaitis Jul 21 '14 at 10:55

1 Answers1

0

It's late, but still talk about this that I also struggled with everyauth and express 4.x.

If you are using express 4.x, install express-session by npm install express-session

using the following code, some other code is the same as the example by the everyauth.

var session = require('express-session');
...
var app = express();
app.use(session({secret : "anything you want"}));
app.use(everyauth.middleware());