I'm trying to write a python script that will pull some data from Nightbot through the API and eventually write that data to a .txt file so I can display it on screen while streaming.
However, I've run into problems authenticating with the API. Every time I run the script, I get a 400 error back. I know that my syntax is probably wrong somewhere but I can't seem to figure out what's wrong here.
import requestsimport json##Authorization POST Request# defining the api-endpointAPI_ENDPOINT = "https://api.nightbot.tv/oauth2/token"# your API key hereCLIENT_ID = "XXX"CLIENT_SECRET = "YYY"DATA = {'grant_type':"client_credentials", 'client_id' : 'CLIENT_ID', 'client_secret' : 'CLIENT_SECRET', 'scope': 'commands'}# sending post request and saving response as response objectr = requests.post(API_ENDPOINT, data=DATA)print(r)