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 of
facebookis 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?