how to refresh an oauth token when using the Facebook iPhone SDK

前端 未结 6 2004
被撕碎了的回忆
被撕碎了的回忆 2021-02-04 07:18

I\'m using the Facebook SDK for iOS in my app: http://github.com/facebook/facebook-ios-sdk

The oAuth token expires after about 2 hours. How can I \"refresh\" the oAuth

6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-04 08:19

    Facebook's implementation of OAuth doesn't support token refresh.

    You have 2 types of access_tokens in Facebook. Short term token, which is given by default and a long term token which is given if you request offline_access. If refresh token were supported, it was the same as giving a offline_access token for all apps.

    As long as the user has an active facebook session on your web control, you can request a new access_token just by accessing https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=http://www.facebook.com/connect/login_success.html&response_type=token or probably some iOS SDK command that does the same (never worked with it so I can't tell). This kind of request will not ask the user to login again, but will use the previous session that was created during the first login.

提交回复
热议问题