扩展60天Facebook令牌 [英] Extending 60 days Facebook token

查看:150
本文介绍了扩展60天Facebook令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Hybridauth与Facebook连接。一切都很好,在那一点上; - )

I'm using Hybridauth to connect with Facebook. Everything works well at that point ;-)

我得到一个令牌,当我在 https://developers.facebook.com/tools/debug/ 我看到有2个月到期。

I get a token and when I check it at https://developers.facebook.com/tools/debug/ I see it has 2 months expiration.

几天后,例如50天,我看到令牌将在10天内到期。

After some days, for example, 50 days, I see the token will expire in 10 days indeed.

我尝试用方法记录(并在其他StackOverflow中描述)问题):

I try to extend with method documented (and described in other StackOverflow questions) with:

https://graph.facebook.com/oauth/access_token?             
client_id=APP_ID&
client_secret=APP_SECRET&
grant_type=fb_exchange_token&
fb_exchange_token=EXISTING_ACCESS_TOKEN

然后我收到另一个令牌,但如果我检查到新的令牌工具调试页面,它返回相同的到期时间(在示例中为10天)...而且在10天内,旧的令牌和新的令牌已过期。

Then I receive ANOTHER token, but if I check that new token in the "tools debug" page, it returns the same expiration time (10 days in the example) ... and indeed, in 10 days, the old token and this new one are expired.

然后...如何获得工作的扩展令牌?

Then ... how can I get a working extended token ?

编辑特定问题

在我的情况下,用户将他们的Facebook连接到他们的帐户,然后我可以从他们的时间线每天获得新照片,显然我不希望他们连接(或单击任何按钮)每60天更新一次。我想这可以像其他网站一样自动永远(因为没有更多的offline_access权限)。

In my case, users connects their facebook to their accounts and then I can get each day new photos from their timelines, and obviously I don't want them to connect (or click any button) each 60 days to renew this. I guess this can be automated forever (since there's no more offline_access permission) as other websites do.

如何让用户将他们的FB帐户连接到我的网站,那么我有一种方法可以在他的时间线中永远获取新内容?

How can let a user to connect their FB account to my site, and then I have a way to grab new content in his timeline forever ?

推荐答案

你必须重定向再次向用户添加登录对话框网址,如 https:// developers.facebook.com/docs/facebook-login/access-tokens/#expiredtokens

You have to redirect to user to the login dialog url again, as described in https://developers.facebook.com/docs/facebook-login/access-tokens/#expiredtokens


如果访问令牌无效解决方案是使用户再次登录,此时您将能够代表他们再次进行API调用。您的应用程序用于新用户的登录流程应该确定您需要采用哪种方法。

If the access token becomes invalid, the solution is to have the person log in again, at which point you will be able to make API calls on their behalf once more. The login flow your app uses for new people should determine which method you need to adopt.

通常应该不需要用户操作如果您不要求更多权限,请重定向。

Normally there should be no user action required when redirecting, if you don't request more permissions.

这篇关于扩展60天Facebook令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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