具有较长有效期的 Facebook 访问令牌
我正在尝试按照本教程获取具有更长有效期的令牌时间 。 Facebook 连接是在客户端(Js sdk)完成的。我采取的步骤是:
- 在我的应用程序设置页面上启用“弃用offline_access”
- 以正常方式检索access_token
- curl "https: //graph.facebook.com/oauth/access_token?
client_id=APP_ID& client_secret=APP_SECRET& grant_type=fb_exchange_token& fb_exchange_token=access_token"
这总是返回完全相同的访问令牌,过期时间为 2 小时,难道它不应该返回一个有效期为 60 天的令牌(与 access_token 相同或不同)吗?
谢谢
I am trying to follow this tutorial on getting a token with longer expiration time . The Facebook connect is done on the client side (Js sdk). The steps I take are:
- enabled 'deprecate offline_access' on my app settings page
- retreive the access_token as normal
- curl "https://graph.facebook.com/oauth/access_token?
client_id=APP_ID&
client_secret=APP_SECRET&
grant_type=fb_exchange_token&
fb_exchange_token=access_token"
This always returns the same exact same access token with expiration of 2 hours, shouldn't it return a token (same or not as access_token) that is valid 60 days ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
截至目前,根据我的经验,启用“弃用离线访问”设置后添加应用程序的新用户似乎会返回 60 天的令牌。在设置“弃用offline_access”设置之前,老用户的生命周期似乎停留在2小时。
我还有一些测试似乎表明,除了“弃用offline_access”设置之外,还需要设置“增强型身份验证对话框”设置才能获得长期令牌。
As of right now, in my experience, it seems that the 60 day tokens are returned for new users who add the app after the 'deprecate offline_access' setting is enabled. Older users, from prior to setting the 'deprecate offline_access' setting seem to be stuck at 2 hour lifetime.
I also have some tests that seem to indicate that setting the 'Enhanced Auth Dialog' setting in addition to the 'deprecate offline_access' setting is required to get long lived tokens.
您可以使用 HTTP DELETE to
me/permissions
以编程方式将 2 小时令牌设置为过期,这将强制用户重新验证您的应用。这应该会给你一个 60 天的令牌。You can programmatically set the 2hour token as expired using HTTP DELETE to
me/permissions
, this will force the user to re-auth your app. Which should give you a 60 day token.