如何避免要求用户一次又一次登录(连接)我的Facebook应用程序? [英] How can I avoid asking users to login (connect) to my facebook app again and again?

查看:341
本文介绍了如何避免要求用户一次又一次登录(连接)我的Facebook应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发和测试我已经通过我的Facebook帐户授予的Facebook应用程序。然后应用程序被授权访问我的信息等。下次我关闭浏览器,重新打开它,登录到Facebook,然后访问该应用程序,Facebook要我再次登录该应用程序。我可以访问当前的用户ID,但如何自动授权该应用程序(如果用户已经在过去已经授权),而不需要用户在每个会话结束时一次又一次地按下这个登录按钮?

I am developing and testing a facebook app for which I have granted the permissions with my facebook account. Then the app is authorized to access my info, etc. nicely. The next time I close the browser, reopen it, login to facebook successfully then access the app, facebook wants me to login to that app again. I can access the current user id, but how can I automatically authorize the app (if the user has already authorized in the past) without needing the user to press that dread 'Login' button again and again upon each session's end?

推荐答案

更新 - 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.

这篇关于如何避免要求用户一次又一次登录(连接)我的Facebook应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆