douyunhuan9886 2012-06-27 12:45
浏览 75
已采纳

Facebook API - 如何在不需要用户再次登录的情况下存储多个访问令牌?

For my application, I need to be able to get some datas from 0-x FB accounts for each person.

I have the authentication process working, I get the different access tokens, but they become invalid very quickly because, when the user logs in as a different account, the token from the previous one becomes invalid.

Problem is, I need to get the datas I want all at the same time, so I can't ask them to login with their multiple accounts each time they come on the website...

If anyone has an idea...

Thanks for your help =)

  • 写回答

1条回答 默认 最新

  • doujuegai8830 2012-06-27 18:45
    关注

    You can increase 2 table columns in your app namely short_access_token & long_access_token for each user.

    Once user authenticates your app, an access token is generated, store it in short_access_token. Then pass this access token to:

    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

    Once you run this, an access token with 60 days validity will be generated. Store it in long_access_token. Now, use this long_access_token for 60 days.

    You can generate long lived access token only once a day i.e. the first time. Use this long lived access token for your tasks (if you've already got the permission).

    Ref: https://developers.facebook.com/roadmap/offline-access-removal/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀