How to extend facebook access token in python

后端 未结 3 514
夕颜
夕颜 2021-02-06 14:37

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 c

3条回答
  •  执念已碎
    2021-02-06 15:12

    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:

    graph = facebook.GraphAPI(user_short_lived_token_from_client)
    app_id = 'app_id' # Obtained from https://developers.facebook.com/
    app_secret = 'app_secret' # Obtained from https://developers.facebook.com/
    
    # Extend the expiration time of a valid OAuth access token.
    extended_token = graph.extend_access_token(app_id, app_secret)
    print extended_token #verify that it expires in 60 days
    

提交回复
热议问题