Created
September 16, 2018 10:01
-
-
Save miguelBarreiro85/922b3e3b77575a04337452aa3fec213b to your computer and use it in GitHub Desktop.
Function in python written for a school exam
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_auth_token(): | |
global url | |
global secret | |
global clientId | |
global tokenExpirationDate | |
paramUrl = url + 'raspberry' | |
paramData = {'clientId': clientId, | |
'clientSecret': secret} | |
print("Requesting token...") | |
r = requests.post(paramUrl, data=paramData, verify=False) | |
global access_token | |
global token_type | |
print(r.text) | |
response = json.loads(r.text) | |
access_token = response['access_token'] | |
token_type = response['token_type'] | |
tokenExpirationDate = datetime.now() + timedelta(seconds=response['expires_in']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment