Node.js Express/socket.io 与 facebook 的混合应用程序
我在我的node.js 应用程序中使用express/socket.io 组合。到目前为止一切正常。 现在,我需要将facebook 用户 ID 和电子邮件 ID(用户被授权后)存储到会话范围中。我看到有很多选项,但在这里有点迷失..在我的应用程序中,大多数通信都是通过socket.io发生的..最终我想要的是在客户端随时访问用户ID和电子邮件ID...
var express = require("express"),
fs = require("fs"),
app = express.createServer(
form({ keepExtensions: true })
),
io = require("socket.io");
socket = io.listen(app);
I am using express/socket.io combination in my node.js app. So far it's working fine.
Now, I need to store facebook user id and email id (after user being authorized) into session scope. I see there are lot of options and a bit lost here.. in my app, most of the communications happen through socket.io.. ultimately what i want is to access user id and email id anytime in the client side...
var express = require("express"),
fs = require("fs"),
app = express.createServer(
form({ keepExtensions: true })
),
io = require("socket.io");
socket = io.listen(app);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
获得授权后,我建议使用cookie中已有的accessToken,然后通过socket.io发送它,并使用graph.facebook或您自己的数据库获取电子邮件和id。存储用户 ID 和电子邮件的问题是它可能不安全,因为可能会发生会话劫持。
Facebook 拥有自己的安全专家,以确保其不会被劫持。使用它!
After being authorized, I suggest using the accessToken which is already in the cookies and then sending it through the socket.io and fetching the email and the id using graph.facebook or your own DB. The problem with storing user ID and Email is that it could insecure, since session hijacking could happen.
Facebook has its own experts on security to make sure it wouldn't be hijacked. Use it!
这可能会有所帮助:
http://criso.github.com/fbgraph/
获得授权后,您可以存储 会话中的数据
通过express http://expressjs.com/guide.html#session-support< /a>
在非常基本的层面上:
This might help:
http://criso.github.com/fbgraph/
After being authorized you can store the data in your session via express
http://expressjs.com/guide.html#session-support
On a very basic level: