Facebook会话和access_token的当前状态如何? [英] How's the current state of Facebook's session and access_token?

查看:129
本文介绍了Facebook会话和access_token的当前状态如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我还记得更多,每当我们返回一个Facebook会话或access_token时,它都应该有生存时间,并且在我们返回一个用户ID之前,该库应该通过执行以下操作来验证该用户ID是真实的MD5等

Now I can remember more, that whenever we get back a Facebook session or access_token, it should have a life time, and before we get back a user id, the library is supposed to have verified the user id is real by doing MD5, etc.

会话和access_token当前如何工作?还有无限的会话吗?它们通常会在不到2小时内过期吗?的确,如果用户继续使用该应用程序或我们的网站(已连接到Facebook),则可以续签该会话或access_token-到期时间将进一步延长.

How do session and access_token work currently? Is there infinite session any more? Do they normally expire within less than 2 hours? Is it true that if the user keep on using the app or our website (connected to Facebook), then the session or access_token can be renewed -- expiration time will be further extended.

在数据库的users表中存储会话或access_token有什么用吗?我认为,如果没有无限的会话,那么我们可能不必这样做,除非我们知道批处理将在一个小时内完成某件事(例如,进行一些冗长的Facebook API调用).

Is there any use to store the session or access_token in our DB's users table? I think if there is no infinite session, then we probably don't have to, unless if we know our batch processing will do something within an hour (to do some lengthy Facebook API calls, for example).

如果我们请求电子邮件发送许可,并且用户授予了该许可,那么几天后我们有新闻通讯要发送出去时,我们不需要进行会话或access_token来发送电子邮件吗?

What if we request email sending permission, and the user grants it, then won't we need to have a session or access_token to send the email when a few days later when we have a Newsletter to send out?

推荐答案

因此,让我一次解决您的问题.

So let me address your questions one at a time.

  1. 普通的Facebook会话(access_token)仅有效几个小时.
  2. 您可以通过在用户验证您的应用程序时向用户请求"offline_access"扩展权限来获得无限会话.
  3. 要续订"会话,您只需将用户发送回facebook上的身份验证页面即可.之所以会立即发生,是因为他们已经对您的应用进行了身份验证,因此他们的用户将被重定向回您的网站并继续运行,而无需注意身份验证.
  4. 除非有offline_access权限,否则没有任何理由可以存储访问令牌.如果您具有脱机访问权限,则可以将其存储,否则,最好在他们每次提出新请求时从他们的cookie或会话中读取它.
  5. 电子邮件扩展许可不是允许向他们发送电子邮件",而是阅读其电子邮件地址的许可.如果被授予此权限,则可以从Graph API获取用户的电子邮件地址,然后保存该电子邮件地址.拥有电子邮件地址后,您可以像使用任何普通电子邮件系统一样向他们发送电子邮件.您不需要访问令牌.

这篇关于Facebook会话和access_token的当前状态如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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