warnings.filterwarnings('ignore', category=DeprecationWarning)
FACEBOOK_APP_ID = 'XXXXXXXXXXXXXXX'
FACEBOOK_APP_SECRET = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
FACEBOOK_PROFILE_ID = 'XXXXXX'
oauth_args = dict(client_id=FACEBOOK_APP_ID, client_secret=
    FACEBOOK_APP_SECRET, grant_type='client_credentials')
oauth_curl_cmd = ['curl', 'https://graph.facebook.com/oauth/access_token?' +
    urllib.parse.urlencode(oauth_args)]
oauth_response = subprocess.Popen(oauth_curl_cmd, stdout=subprocess.PIPE,
    stderr=subprocess.PIPE).communicate()[0]
try:
    oauth_access_token = urlparse.parse_qs(str(oauth_response))['access_token'
        ][0]
except KeyError:
    print('Unable to grab an access token!')
Programmatically getting an access token for using the Facebook Graph API