【发布时间】:2014-09-11 08:34:19
【问题描述】:
我正在尝试构建一个简单的 nodejs 应用程序,该应用程序可以使用 express 和everyauth 登录 facebook。按照 README 教程 here,我在 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));
当我启动我的应用程序时,我访问了 localhost:3000/auth/facebook,它正确地重定向到了 facebook。我在那里授权应用程序,它将我重定向到 localhost:3000/auth/facebook/callback。但是,我的应用在这里记录了以下错误:
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.
我做错了什么?
【问题讨论】:
-
您是否尝试按照项目页面中的说明启用调试:github.com/bnoguchi/everyauth#debugging---logging-module-steps
-
此外,队列中至少有一个 facebook 问题和另一个具有 express 4 兼容性的问题...您可能想查看问题队列。 Everyauth 很久没有主动更新了。您可能需要调查 Passport 或其他替代方案。
标签: facebook node.js session express everyauth