我通过重定向到 facebook 身份验证页面 $fb->getLoginUrl()
实现了身份验证,当此流程结束时,我将获得一个用户访问 token 。
根据https://developers.facebook.com/docs/facebook-login/access-tokens/#extending应该是生命周期很短的,而我的今天之后两个月就到期了。
这是预期的行为吗?
如果是 - 在什么情况下您会交换 token ?
如果没有 - 我错过了什么?
UPD
我刚刚创建了一个新的应用程序,并且再次 - 新的用户访问 token 过期1395567887(大约 2 个月后)
(来自 token 调试器的信息)
最佳答案
取决于您正在实现的用例场景。
如果您使用的是应用程序,并且 token 用于应用程序权限(例如,如果您使用 getLoginUrl
来验证应用程序)等,则:
If your app publishes on behalf of its users and requires an access token with no expiration time for the purpose of publishing, you should use an App Access Token. An App Access Token is signed using your app secret and will not expire; it will be invalidated if you re-key/reset your application secret.
编辑
默认情况下,我的所有应用程序都有 2 个月的访问 token ,这就是 FB docs 中所述的内容。
Access tokens on the web often have a lifetime of about two hours, but will automatically be refreshed when required.
就像这里描述的:
服务器端流程授予 2 个月的长期 token
关于php - 通过基于重定向的身份验证收到的 token 是否预期是长期存在的 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21278720/