iosswiftfacebookfacebook-ios-sdkfbsdkloginkit

How To refresh FBSDK Access Token From iOS APP


I am using FBSDKLoginKit in my app for the authentication purpose of the user.

I need to keep the user logged in unless and until user specifically choose to log out from app.

For this I need to refresh the FBSDKLoginKit token without showing user the login screen.

So can any one help how i can achieve it?

EDIT

I want user to login only once and let user use the application directly when user comes back on another day. As FBSDK token get's expired in 60 Days so need a way to refresh automatically when user comes back to app

EDIT2

I found one method named refreshCurrentAccessTokenbut it's still unclear how to use it as not sure when to call it.


Solution

  • According to Facebook doc. The access token will be refreshed automatically per day if you make requests to Facebook server.

    Native mobile apps using Facebook's SDKs will get long-lived access tokens, good for about 60 days. These tokens will be refreshed once per day when the person using your app makes a request to Facebook's servers. If no requests are made, the token will expire after about 60 days and the person will have to go through the login flow again to get a new token.