Skip to content

Instantly share code, notes, and snippets.

@miguelBarreiro85
Created September 16, 2018 10:01
Show Gist options
  • Save miguelBarreiro85/922b3e3b77575a04337452aa3fec213b to your computer and use it in GitHub Desktop.
Save miguelBarreiro85/922b3e3b77575a04337452aa3fec213b to your computer and use it in GitHub Desktop.
Function in python written for a school exam
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