Reputation: 45
Using Facebook API I am trying to get values of insights of my Facebook post. eg: Number of likes, Comments etc on my post. After every two hour Access Token get expired. How should I refresh Access Token programmatically in python?
import json
import requests
token='EAAGKjHZAzRuMBAIoZCf66iwGFB09SJUPavJNPOZAGrrQUNoYZBh5KHbVZArFQFiQFCzFSDNsmsW5hhaPiMys1eQLIhOlZCuYN0gMASuYyTliPjl4AIezXz14Wsl66ZAYoqmqqCcXRBpCfAW0lUACTwRxOkhqKqEnXpyTBoBTQ7naL9ZC0wU3iXN1MKD35Kxec9YZ
url="https://graph.facebook.com/v3.2/313052155994024/insights/post_reactions_like_total,post_reactions_love_total,post_reactions_wow_total,post_reactions_haha_total?access_token="
response = requests.get(url+token)
data = json.loads(response.text)
Upvotes: 1
Views: 214
Reputation: 73984
There is no way to automatically refresh a Token, just use an Extended Page Token instead: https://developers.facebook.com/docs/facebook-login/access-tokens/expiration-and-extension
Upvotes: 2