Created
September 21, 2019 13:26
-
-
Save ejdoh1/c1953bc81a099fa0a0bab0484435336a to your computer and use it in GitHub Desktop.
Desko change desk colour sample
This file contains hidden or 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
| #!/usr/bin/python3 | |
| import requests | |
| import json | |
| CLIENT_ID = '<CLIENT_ID>' | |
| CLIENT_SECRET = '<CLIENT_SECRET>' | |
| TOKEN_URL = 'https://desko.auth.ap-southeast-2.amazoncognito.com/oauth2/token' | |
| DESK_COLOUR_URL = 'https://desko.planternal.com/api/desk/colour' | |
| COLOUR = { | |
| 'red': 0, | |
| 'green': 100, | |
| 'blue': 255 | |
| } | |
| access_token = json.loads( | |
| requests.post( | |
| url=TOKEN_URL, | |
| data={ | |
| 'grant_type': 'client_credentials', | |
| 'client_id': CLIENT_ID, | |
| 'client_secret': CLIENT_SECRET, | |
| } | |
| ).content | |
| )['access_token'] | |
| r = requests.post( | |
| url=DESK_COLOUR_URL, | |
| headers={ | |
| 'Authorization': access_token | |
| }, | |
| json=COLOUR | |
| ) | |
| print("Received response code:",r.status_code) | |
| print("Received message:",json.loads(r.content)['message']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment