How to extend my facebook graph API token in python? -


I am currently mining Facebook using Python. Up to now, I get an access token for this Web site via Graph API version 1.0 (I need 1.0):

But the token coming to this site Time expires. In about 1 hour, how can I expand this token in Python? I have already seen how in PHP, but, for no reason, I have to be with Python for my project only

There are 4 types of tokens in Facebook: users, apps, pages and clients (). Each of these token types has their permissions, for example, you can post on behalf of a user using App Access Token (once they have given you permission) but user / user to drag the position Access token is required. Web user access tokens are short-lived (~ 1-2 hours) and need to be converted to long lasting (60 days) access tokens.

In Python, you can extend the token server-side assuming that you are calling the GraphAPI extension_access_token method using facebook-sdk (pip-install facebook-sdk).

  import facebook user_access_token = 'USER_ACCESS_TOKEN' # Initial client-side app_id = 'YOUR_UNIQUE_APP_ID' # was found on the developer.facebook.com app_secret = 'YOUR_APP_SECRET' # Found on developer Fashionbook.com #fb graph object graph = facebook GPAPI (User_Account_Token) # Increase it Expand_access_token method extended_token = graph.extend_access_token (app_id = app_id, app_secret = app_secret) #Token confirmation now ends in ~ 60 days or 5184000 seconds Extended token  
< P> Now the tokens have been extended, you can store and carry out an active web client from the user.


Comments