Forum Sitebox Refresh or extend FB tokens?

Discussion and help relating to the PlayerIO webpage and Facebook app hosting solution, Sitebox.

Refresh or extend FB tokens?

Postby unboundedgames » February 10th, 2015, 11:13 pm

Hi all,
I've had a lot of Facebook API errors [4%] and am thinking that most are coming from expired tokens. So I'm wondering if sitebox does any token refreshing in the background that I might be able to access in the normal '.parameters' manner I grab it client-side when it first loads. Also I'm wondering if it's possible to just extend the token duration instead? This probably is obvious to everyone else, but I'm borderline retarded when it comes to the languages involved in the sitebox stuff, and still a little baffled as to what is actually shown to me and if there's stuff in the background I'm not aware of etc. So please forgive me if this is a dumb question, but looking over some Facebook docs I didn't feel confident in my chances of success extending or refreshing the token properly. Any assistance is sincerely appreciated. :D
Paid Member
Posts: 48
Joined: February 17th, 2013, 11:40 pm

Re: Refresh or extend FB tokens?

Postby Guillaume » February 21st, 2015, 4:20 pm

I don't know if you have solved your problems, but i worked on theses things some weeks ago.

You have 2 solution about that:

1. You can generate LongAccess token for your game. But for that, you need to do a special WebRequest from your ServerSide ONLY. This token will be valid for 60 Days (or 30 i don't remember). Generally they are used for Mobile Games (if you cache the AccessToken) or for the ServerSide if you need to be able to access you players account even when they are not connected (through this LongAccess token).

It may be easier to implement, but you must keep in mind that i have read that if you do a lot LongAccess Token creation request, Facebook may consider that you application is "spamming" user. So implement it carefully, for the good things. It must be not often !

See the official documentation here !

As you can see, it's not recommanded at all in a "normal" workflow.

So the second solution:

2. Manage the Facebook error, and then call "login" to relogin the player, then obtain a new fresh AccessToken, and continue your normal workflow.

But if you need to do a very automatic and transparent workflow, i can understand that it's maybe "not cool" at all to check and to do some "special" case.

On my game, i have developed a little API that i called "SafeFB". It mimic Facebook API method calls (in C#), but my API manage to see if there is permissions or token timeout error before calling my success delegate or my error delegate. If one of theses exception is found, then it try to call Login to resolve the problem, then when Login Workflow is finish, it recall the original method attended, and THEN if it's success...then success, otherwise i call my error workflow.

So, normally, if it's only a token expiration, it will always works transparently, as Login don't need any additional permission in this case.

If you use C# and Unity, just tell me, i will try if i can post my little API here.
Posts: 277
Joined: March 28th, 2014, 1:59 am
Location: France

Return to Sitebox