Skip to content

Instantly share code, notes, and snippets.

@micheleberardi
Last active September 9, 2019 22:47
Show Gist options
  • Save micheleberardi/77564539025b1e14888bb481d3a9bf40 to your computer and use it in GitHub Desktop.
Save micheleberardi/77564539025b1e14888bb481d3a9bf40 to your computer and use it in GitHub Desktop.
Creazione di un token lunga durata
#!/usr/bin/env python3.4
# -*- coding: utf-8 -*-
"""
Request Token long termn
"""
__author__ = "Michele Berardi"
__copyright__ = "Copyright 2018, "
__license__ = "GPL"
__version__ = "1.0.1"
__maintainer__ = "Michele Berardi"
__email__ = "michele@berardi.com"
__status__ = "Production"
import requests
def get_token(access_token_url):
try:
response = requests.get(access_token_url)
if response.ok:
access_token = response.json()
user_long_token = access_token['access_token']
return user_long_token
except:
return "error"
if __name__ == "__main__":
app_id = '512225539574368'
app_secret = '9dc19451ce6a58d4e22e9634053f443f'
user_short_token = 'EAAHR3c1UymABAARMW95G9U3NlzSE8lvWbmnJtGr7GauH3aofCCCiZBcxBfZBNN1ZAxOOWMEzzFgJLZAR2QHYtvIMZChB4ykU5U6ZAgvjdRo3lKffPeLJTPDztQZC29lN3mG4rVFFzuQibSVGhbr9Onhzf6oxfGXNbOSD9Sag5D3XjTgoH2LrfEfkUrj0SeZCXoNr9xaT7ZBrFoAZDZD'
access_token_url = "https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id={}&client_secret={}&fb_exchange_token={}".format(
app_id, app_secret, user_short_token)
token = get_token(access_token_url)
print(token)
"""
[OUTPUT]
EAAHR3c1UymABAC84RLZAHWK8kZA9M8bKrgMUOZCJttwX4mk9kCTIc4afNyiJVPrhtHDrZCKPrb58ZCMT3v4SHnGKZCRRTOYOVFppk1iYEJYqSPZCWMAXtyvhkxpjZCKtBiqFa9ZA1jc5Vv5sAWEjiyvu43w7iWTZBcLIoZD
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment