Extending expiry date of facebook access token in graph api beyond 2 months

HimalayanCoder picture HimalayanCoder · Jan 17, 2013 · Viewed 14.8k times · Source

I am working on facebook page wallpost automation using python

I have automated posting on a fb page that i own by using facebook graph api post So i do this by sending a HTTP POST request to https://graph.facebook.com/mypagename/feed

with access_token and message as POST paramaters

I generate the access token by using graph api explorer by selecting my app that i am using and giving it permission to manage my pages

Intitially the access_token use to expire in 2 hours

To extend the expiry date to 2 months i send HTTP GET request to this url

https://graph.facebook.com/oauth/access_token?client_id=my_app_id&client_secret=my_app_secret&grant_type=fb_exchange_token&fb_exchange_token=old_access_token

the response is a json string with new access_token and expiry time in seconds

the expiry time of new access token is now 60 days.

Now is it possible to extend expiry time beyond 60 days??

Answer

Harsh Gupta picture Harsh Gupta · Oct 17, 2013

You can use following api from facebook to refresh token life to 60 days and just when the token is about to expire, call the same api again with-in 60 days to refresh its life back to 60 days from that point of time Token expire is present in expires parameter and its value is in seconds

Replace CLIENT_ID and CLIENT_SECRET with their actual value

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

in ACCESS_TOKEN, put the actual token value without appending "access_token="