且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何避免要求用户一次又一次登录(连接)我的Facebook应用程序?

更新时间:2022-12-26 19:40:40

更新 - offline_access已被弃用。阅读这篇文章了解更多详情: https://developers.facebook.com/roadmap/offline -access-removal /

UPDATE - offline_access has been deprecated. Read this post for more details: https://developers.facebook.com/roadmap/offline-access-removal/

您将需要请求具有offline_access的令牌,以便您一次又一次地使用它们的身份验证令牌。那么你将需要自己设置一个cookie来存储指示用户是谁的东西。 Facebook在身份验证中不支持记住我功能,因此您必须自己构建它。将访问令牌存储在数据库中,并设置cookie以标识用户。

You will need to request a token that has offline_access so that you can use their authentication token over and over again. Then you will need to set a cookie yourself that stores something indicating who the user is. Facebook does not support a "remember me" feature in their authentication so you have to build it yourself. Store the access token in your database and set the cookie to identify the user.

除非您正在构建一个非常具体的原因,例如仅在工作电脑上运行的应用程序我真的鼓励你不要实现这个功能。 facebook连接授权被用户很好理解,非常易于使用。如果您让用户每次按下按钮,您将获得更多的安全性。只要确保你使这个可选。你不知道有人在公共电脑上。

Unless you are building this for a very specific reason like an app that runs on work computers only, I would really encourage you to not implement this feature. The facebook connect authorization is well understood by users and is very easy to use. You are going to get a lot more security if you make your users press the button every time. Just make sure you make this optional. You never know if somebody is on a public computer.