Facebook:自动刷新长期访问令牌 [英] Facebook: Refreshing long-lived access token automatically

查看:73
本文介绍了Facebook:自动刷新长期访问令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为已将其Facebook帐户关联到我的应用程序的用户存储长期访问令牌.自 offline_access 令牌消失以来,这些长期存在的令牌的有效期为约60天".但是,当用户与Facebook互动时,他们可以刷新自己.根据文档:

当使用您的应用的用户向Facebook的服务器发出请求时,这些令牌将每天刷新一次.如果没有请求,令牌将在大约60天后过期,该人将不得不再次通过登录流程来获取新令牌.

我想知道的是向Facebook服务器发出请求的构成.用户是否必须登录Facebook网站,移动应用程序或在某处使用赞"按钮?还是我的代表用户提出请求的应用程序也算在内?

此外,刷新令牌后,还会刷新60天吗?还是它们的刷新时间较短?

我无法在文档或此处提出的其他问题中找到这些具体答案,所以在此先感谢可能有更多详细信息的任何人.

解决方案

粘贴的上一行很重要:使用Facebook SDK的本地移动应用程序将获得寿命很长的访问令牌,有效期约为60天

您拉出的部分仅涉及使用Facebook SDK的iOS和Android应用-SDK进行API调用以扩展令牌,该令牌仅适用于SDK和本机移动SDK生成的令牌-

其他应用(例如网站,facebook.com上的应用)需要使用文档其他部分中记录的登录流程,并要求用户在其浏览器中登录Facebook

I'm storing long-lived access tokens for users of my application that have associated their Facebook accounts to it. Since the demise of the offline_access tokens, these long-lived tokens have an expiry date of "about 60 days." However, they can refresh themselves when the user interacts with Facebook. According to the documentation:

These tokens will be refreshed once per day when the person using your app makes a request to Facebook's servers. If no requests are made, the token will expire after about 60 days and the person will have to go through the login flow again to get a new token.

What I'd like to know is what constitutes making a request to Facebook's servers. Does the user have to log in to the Facebook website, mobile app, or use a Like button somewhere? Or does my application making a request on behalf of the user count as well?

Also, when the tokens are refreshed, are they refreshed for another 60 days? Or are they refreshed for a smaller duration?

I wasn't able to find these specific answers in the documentation or in other questions asked here, so thanks in advance to anyone who might have more details.

解决方案

The previous line to the one you pasted is important: Native mobile applications using Facebook's SDKs will get long-lived access tokens, good for about 60 days

The section you pulled out refers only to iOS and Android apps using the Facebook SDK - the SDK makes an API call to extend the token, which will only work from the SDK and for tokens produced by the native mobile SDKs-

Other apps (e.g websites, apps on facebook.com) need to use the login flows documented elsewhere in the documentation and require the user to be logged into Facebook in their browser

这篇关于Facebook:自动刷新长期访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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