Tuesday, February 10, 2015

Get a Facebook API Access Token That Never Expires

Standard
I’ve been working on a few scripts that performed some minor data collection using the Facebook Graph API as a data source. Ideally, I wanted this script to be able to run several times a day automatically, however Facebook grants access tokens that expire after 1-2 hours. Since I’m the only one that is going to run this script, I only needed access to my Facebook data and I didn’t want to have to re-authenticate every few hours. Luckily, Facebook provides a permission parameter to get a “long-lived” access token from Oauth called offline_access!

https://graph.facebook.com/oauth/access_token?
client_id=_APP_ID_&
client_secret=_APP_SECRET_&
grant_type=fb_exchange_token
&fb_exchange_token=_ACCESS_TOKEN_ON_STEP_4_


0 comments:

Post a Comment