简体   繁体   English

注销Facebook会使offline_access令牌无效

[英]Logging out of Facebook invalidates offline_access token

I'm getting an offline access token like this: 我得到这样的脱机访问令牌:

https://graph.facebook.com/oauth/access_token?scope=offline_access&client_id=MYCLIENTID&redirect_uri=MYREDIRECTURI&client_secret=MYSECRET&code=MYCODE https://graph.facebook.com/oauth/access_token?scope=offline_access&client_id=MYCLIENTID&redirect_uri=MYREDIRECTURI&client_secret=MYSECRET&code=MYCODE

obviously the MYCLIENTID and stuff have been changed for the sake of this post. 显然,为了这篇文章,MYCLIENTID和内容已更改。 Anyway, as soon as the user logs out of facebook, the key seems to no longer be valid. 无论如何,一旦用户退出facebook,该密钥似乎不再有效。 Am I not requesting offline_access properly (there's still an "expires" value on it, should there be if it is actually getting offline access), or is that just how it works? 我是否没有正确地请求offline_access(仍然有一个“ expires”值,如果实际上正在获得脱机访问,应该存在该值),或者这是如何工作的?

If it's the latter, how can I get a key that will persist, regardless of if the user logs out of facebook? 如果是后者,那么无论用户是否注销Facebook,我如何都能获得一个持久的密钥? I'm sure this is possible, because Tweetdeck can still write to Facebook, even though I'm currently logged out. 我确信这是有可能的,因为即使我当前已注销,Tweetdeck仍然可以写信给Facebook。

expires will still be there but should be set to 0. 过期将仍然存在,但应将其设置为0。

to make it short, you should store the access token somewhere in a database, and use it. 为了简短起见,您应该将访问令牌存储在数据库中的某个位置,并使用它。

from this blog, the first script does that: http://cuneytgurcan.wordpress.com/2011/01/07/php-facebook-cronjob-with-offline-access/ 通过此博客,第一个脚本可以做到这一点: http : //cuneytgurcan.wordpress.com/2011/01/07/php-facebook-cronjob-with-offline-access/

I needed to use this URL instead: 我需要改用以下网址:

http://www.facebook.com/dialog/oauth/?scope=offline_access&client_id=[AppId]&redirect_uri=[redirect_uri]&response_type=token http://www.facebook.com/dialog/oauth/?scope=offline_access&client_id=[AppId]&redirect_uri=[redirect_uri]&response_type=token

Once I switched to that, I got an alert about the offline permissions when I logged into Facebook, and the token remains active after logout. 切换到该位置后,登录Facebook时会收到有关脱机权限的警报,并且注销后令牌仍处于活动状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM