开发者

How to remember a User's access token for Facebook

In order for my application to connect to Facebook, they click on a connect to Facebook button. This button with authorize the user, and when they are authorized, i am able to get their access token by calling facebook.getAccessToken().

But is there a way for the application to remember their credentials so that they don't have to login every time they want to connect to Facebook (w开发者_Go百科ithout storing their access token in some sort of database)?


You can find a good example of doing that in the FB SDK examples using SharedPreferences: https://github.com/facebook/facebook-android-sdk/tree/master/examples/simple/src/com/facebook/android

You can store the access token there, since it expires after an hour or what and the user needs to authenticate again.


If you are asking for offline permission, you can save the token and reuse it (until they either remove your app from their permissions list, or (I think) change their password).

See https://developers.facebook.com/docs/authentication/permissions/ for information on the permissions available (search for offline_access).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜