Facebook OAuth AccessToken 过期
我需要有关 Facebook OAuth 的帮助。我正在尝试为我的网页制作一个 Facebook 新闻提要小工具。我所做的是,我创建了一个 Facebook 登录页面,获取了验证码,然后获取了访问令牌。访问令牌中有一个到期参数。
我的问题是,令牌过期后会发生什么?是否成为新的token人再次登录。我想将其存储在数据库中,以便我可以在浏览网页时随时访问它。
如果我使用访问令牌,它还会过期吗?或者如果在给定的有效期内未使用它是否会过期?
I need help with Facebook OAuth. I am trying to make a facebook news feed gadget for my webpage. What I did is, I created a facebook login page, got the verification code, and then got the access token. There is an expiry parameter in the access token.
My question is, what happens when the token gets expired? Does it become a new token person logs in again. I want to store it in a database, so I can access it anytime I navigate through the webpage.
If I use the access token, will it still get expired? Or does it expire if its not been used for the given expiration time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您最初问题的答案是,访问令牌仅在用户登录时有效。因此,是的,每次登录您的站点时都需要检索新的 access_token。 身份验证流程文档对此进行了详细说明。
为了获得没有过期(或有效期较长)的访问令牌,您需要让用户授权
offline_access
。这应该在您的范围内设置。以下是本文档offline_access 权限的描述>:
然而,这不会让您永远访问。如果用户更改密码或取消对您的应用程序的授权,您将需要让用户重新授权以获得新的 access_token。如果您尝试使用过期的访问令牌,将返回错误消息。这就是为什么拥有一个能够应对此类不测事件的流程非常重要。
The answer to your initial question, is that an access token is only valid whilst the user is logged in. So yes, a new access_token will need to be retrieved every time they log in to your site. This is detailed in the authentication flow documentation.
In order to get an access token which is does not have an expiry (or has a long validity period), you will need to get the user to authorise the
offline_access
. This should be set in your scope.Here's a description of the
offline_access
permission from this documentation:This will not however, give you access forever. If the user changes their password, or deauthorises your application, you will need to get the user to reauthorise it to get a new access_token. If you try to use an out of date access token, an error message will be returned. That's why it's important to have a flow which will allow for such eventualities.
据我所知,您可以通过在用户执行 fconnect 时请求随时访问我的信息权限(offline_access)来实现此目的。
From my knowledge you can achieve this by asking for access my information anytime permission (offline_access) while a user does fconnect.
有关详细信息,请参阅
权限: http://developers.facebook.com/docs/ Reference/api/permissions/
对于过期的令牌:http://developers.facebook.com/blog/post/500/
For Detail information please refer
For Permissions: http://developers.facebook.com/docs/reference/api/permissions/
For expired Token: http://developers.facebook.com/blog/post/500/