Facebook 页面访问令牌 - 这些会过期吗? [英] Facebook Page Access Tokens - Do these expire?

查看:22
本文介绍了Facebook 页面访问令牌 - 这些会过期吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个应用程序,允许用户管理他们的 Facebook 粉丝页面.这需要以下两个访问令牌:

  1. 用户访问令牌
  2. 页面访问令牌

我非常熟悉用户访问令牌,但不熟悉页面访问令牌.

有人知道页面访问令牌的有效期是多久吗?我在 Facebook 网站上能找到的只有这个简洁的段落,其中没有提到任何关于它的到期.

我是否可以假设,如果我使用 offline_access 权限请求用户访问令牌,页面访问令牌也将无限期地持续下去(除非用户更改其密码或手动取消对我的应用的授权)?

我之所以这么问是因为我想知道我应该多久查询一次 Facebook Graph API 并获取页面访问令牌.我应该在用户注册时简单地请求一次吗?或者我应该在他们不断变化的情况下为每个 API 调用请求一个?后者显然更费力!

解决方案

当生成页面令牌的用户的访问令牌过期时,页面令牌也会过期.编辑 6.28.2013:如果您扩展用户访问令牌并获得一个新的页面访问令牌 对于用户,除非用户取消对您的应用的授权,否则该页面令牌不会过期.

离线访问现已弃用,但您可以将访问令牌延长至持续 60 天.如果您扩展用户的访问令牌,那么从该用户帐户生成的页面令牌也将延长其到期时间以匹配 将不会到期(已于 6.28.2013 编辑).页面令牌的值在扩展后可能会发生变化,因此请确保在扩展用户令牌后从用户的/accounts图连接中获取新的页面令牌.

您可以每天继续延长这些访问令牌一次.因此,您应该每天在用户与您的应用交互时重新生成访问令牌.

https://developers.facebook.com/docs/facebook-login/访问令牌/#pagetokenshttps://developers.facebook.com/docs/facebook-login/访问令牌/#extendinghttps://developers.facebook.com/docs/facebook-login/
https://developers.facebook.com/roadmap/offline-access-removal/https://developers.facebook.com/blog/post/2011/05/13/how-to--handle-expired-access-tokens/

I'm building an app that allows users to administrate their Facebook Fan Pages. This requires the following two Access Tokens:

  1. A User Access Token
  2. A Page Access Token

I'm quite familiar with User Access Tokens, but not with Page Access Tokens.

Does anybody know how long the Page Access Token remains valid? All I can find on the Facebook website is this succinct paragraph, which doesn't mention anything about it's expiry.

Can I assume that if I am requesting the User Access Token with the offline_access permission the Page Access Token will also last indefinitely (unless the user changes their password or manually deauthorises my app)?

I'm asking because I want to know how often I should query the Facebook Graph API and acquire Page Access Tokens. Should I simply request them once when the user registers? Or should I request them one each API Call in the event they continuously change? The latter is obviously more taxing!

解决方案

Page Tokens expire when the access token expires for the user that the page token was generated from. Edit 6.28.2013: If you extend the user access token and obtain a new page access token for the user, that page token will not expire unless the user de-authorizes your app.

Offline access has now been deprecated, but you are allowed to extend an access token to last for 60 days. If you extend the user's access token, then the page tokens generated from that user account will also have their expiration extended to match will not expire (edited 6.28.2013). The value for the page tokens may change after being extended, so be sure to grab new page tokens from the user's /accounts graph connection after extending the user token.

You can continue to extend these access tokens once per day. So you should regenerate the access tokens each day that the user interacts with your app.

See https://developers.facebook.com/docs/facebook-login/access-tokens/#pagetokens https://developers.facebook.com/docs/facebook-login/access-tokens/#extending https://developers.facebook.com/docs/facebook-login/
https://developers.facebook.com/roadmap/offline-access-removal/ https://developers.facebook.com/blog/post/2011/05/13/how-to--handle-expired-access-tokens/

这篇关于Facebook 页面访问令牌 - 这些会过期吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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