-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathdebug_access_token.py
More file actions
22 lines (15 loc) · 962 Bytes
/
debug_access_token.py
File metadata and controls
22 lines (15 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from defines import getCreds, makeApiCall
import datetime
def debugAccessToken( params ) :
endpointParams = dict() # parameter to send to the endpoint
endpointParams['input_token'] = params['access_token'] # input token is the access token
endpointParams['access_token'] = params['access_token'] # access token to get debug info on
url = params['graph_domain'] + '/debug_token' # endpoint url
return makeApiCall( url, endpointParams, params['debug'] ) # make the api call
params = getCreds() # get creds
params['debug'] = 'yes' # set debug
response = debugAccessToken( params ) # hit the api for some data!
print ("\nData Access Expires at: ") # label
print (datetime.datetime.fromtimestamp( response['json_data']['data']['data_access_expires_at'] )) # display out when the token expires
print ("\nToken Expires at: ") # label
print (datetime.datetime.fromtimestamp( response['json_data']['data']['expires_at'] )) # display out when the token expires