在阅读 Facebook 关于 offline_access permission removal 的帖子时,我对他们提到的短期和长期访问 token 感到非常困惑。
The duration for which a given access token is valid depends on how it was generated
但是我没有找到任何进一步的信息。
有人对这个确定过程的详细运作方式有深入的了解吗?
最佳答案
您的应用为 Client-Side authentication 获取的访问 token 是短暂的(大约 2 小时),但您可以使用 new endpoint 来延长它并获得一个长期存在的 token 。使用有效 访问 token 。 在Handling Invalid/Expired Access Tokens它在 Desktop Web and Mobile Web apps which implement a authentication with the Javascript SDK 下说:
Calling FB.getLoginStatus() or ensuring status: true is set when you call FB.init() means that the next time a user lands on your application and is signed into Facebook, the authResponse object you are passed as a result of those calls will contain a fresh, valid access token.
In this case, its simply the act of the user using your application which implicitly generates a new access token.
如果您使用 Server-Side authentication flow 那么您将自动获得一个长生命周期 token (大约 60 天)。 到期后,您必须让用户在同一流程中重新进行身份验证(代码交换)。
您当然可以同时使用这两种方法,这样您就可以在服务器中获得一个长期存在的 token ,在客户端获得一个短期存在的 token 。
关于Facebook 长期和短期访问 token ,以及它们在 offline_access 删除后的到期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10487049/