0

可能重复:
自offline_access弃用后如何扩展访问令牌有效性

我尝试为我的应用程序获取长寿命访问令牌(60 天到期时间)。但是我所有的测试只给了我一个简短的标记。

我所做的 :

  • 首先做一个经典的“身份验证”来获得一个短期访问令牌。所以网址:GET graph.facebook.com:443/oauth/access_token?redirect_uri={my_callback}&code={the_code_given_by_fb}&client_id={my_client_id}&client_secret={my_client_secret}

=> 给我两个数据 access_token(一个长字符串)并过期(大约 4000 秒)

  • 然后我想将我短暂的生命访问转变为长期访问,所以我尝试调用:

GET graph.facebook.com:443/oauth/access_token?redirect_uri={my_callback}&code={the_code_given_by_fb}&client_id={my_client_id}&client_secret={my_client_secret}&fb_exchange_token={short_life_access_token}&grant_type=fb_exchange_token

=> 这个电话给我,和第一个电话一样的数据(所以没有长寿令牌)

我也尝试: GET graph.facebook.com:443/oauth/access_token?client_id={my_client_id}&client_secret={my_client_secret}&fb_exchange_token={short_life_access_token}&grant_type=fb_exchange_token

=> 相同的结果

所以我不明白我们必须做什么才能获得长寿命的访问令牌?

4

1 回答 1

0

You have done correctly. You have extended the short lived access token. Now store that in Database and use it. After 60 days, page admin user will have to come back to your app in that 60 days to get a new access token with the extended time on it.

FYI offline access removal

From the DOC

    If you pass an access_token that had a long-lived expiration time, the endpoint will  
 simply pass that same access_token back to you without altering or extending the expiration time.
于 2012-05-24T10:59:54.580 回答