I am using the Python facebook-sdk client library. I currently have a short-lived access token obtained from https://developers.facebook.com/tools/accesstoken/ that I copy the code from the site into my code for authentication.
graph = facebook.GraphAPI(access_token)
This token however expires after 60-mins. I am looking to extend this to a 60 day-long lived token so that don't need to manually copy in new every time it expires. I can find numerous answers on how to do this in different formats, however not python (or at least not simply without log in page etc.).
[for reference, the code I will be using is only intended for my use, and as such, I am not looking to create a log in page. I just want to be able to extend the token I already have].
According to their subsection on extending short lived client tokens, you'll need to take in your short lived client token and, having filled in the relevant app data, send a GET request from your server to the following endpoint:
The response will contain your long-lived access token which can then be passed back to the client or used on your server. If you don't currently have a module for performing HTTP operations, I highly recommend Requests.
here's an edited version , compatible with latest api versions:
Not sure if this was available in python's FB API when the question was originally asked, but a neater approach to extend the expiry of the access token would be: