Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get a new access token after expiration without a page reload?

First, I want to note that I do not want to request the offline_access extended permission. It's there for a reason but this isn't it.

I am creating an html5 app using the Facebook Javascript API. The user is on a single page for a long time playing the game. I get an access token at the beginning of the flow with FB.getLoginStatus but this token expires at some point and so I am then unable to query Facebook for the user.

I have tried calling FB.getLoginStatus again when the first token fails but this does not appear to be giving me a new access token.

Is the only way to reload the page? Kind of sucks because the user's state is disrupted.

like image 804
Brad Dwyer Avatar asked Oct 08 '22 15:10

Brad Dwyer


1 Answers

FB.getLoginStatus will reauthenticate a user to your application and will give you a new access token to work with. You should be able to get the new token from response.authResponse.accessToken.

Are you receiving any particular error after the first token fails?

like image 146
Jordan Avatar answered Oct 18 '22 09:10

Jordan