1

I'm running a node.js server app, using everyauth for my authentication scheme and attempting to reach out to the Facebook API from my server. The way I currently handle this once the user is logged in (via everyauth using the Facebook module) is:

var oauth = everyauth.facebook.oauth;
oauth.get('https://api.facebook.com/method/fql.multiquery?format=json&queries=' + multiquery, req.session.auth.facebook.accessToken, function (err, data) { // do stuff here });

This works initially but after a few minutes, typically around 10m of inactivity, I start getting an expired token response from the Facebook API:

Error validating access token: Session has expired at unix time...

After reading some Facebook docs it seems as if most access tokens should last for a default 2 hours so I'm wondering if I'm not forming the API call in the right way. Any suggestions/ideas welcome, thanks!

EDIT:

Just a bit more info, the expire unix time returned from the error call is indeed less than the current time, just not sure why it would be so short. In the meantime I'll do a bit more debugging...

ghjunior
  • 119
  • 10

1 Answers1

0

Did you know that if you include the "offline_access" option in the scope when requesting FB auth, the access token will never expire.

http://developers.facebook.com/docs/reference/api/permissions/#extended_perms

This may not be ideal for you as it requires extended permissions, but may provide a workaround.

Carol Skelly
  • 351,302
  • 90
  • 710
  • 624