开发者

FBGraph session expiration

Currently i'm developing a side project with heavy Facebook integration. The user signs in via omniauth and then i use their access_token in conjunction with fb_graph to get their data. But after approx. 30 minutes i get this error:

OAuthException :: Error validating access token: Session has expired at unix time 1317304800. The current unix time is 1317306973.

How can i possible catch this error and fix it? It happens randomly so i think a before_filter on application_controller level is the best option. Then i want to catch the url where they are on or are b开发者_开发知识库eing redirected to so that i can redirect the user to "/auth/facebook" and let them return to the url they wanted to go.

Another option is an observer? Is this possible to observe the user and if this error occurs catch it and remember the current_url or the redirect url and then redirect the user to /auth/facebook for a new access_token..

What do you think is the best option? Or do you have a better solution?

Thanks!


The access token expires in after "X" time. You could ask for offline_access permission and then save it in your database

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜