Guest User

test

a guest
Sep 2nd, 2021
52
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def makeRequest(request:str,authKey:str,clientId:str):
  2.  
  3.     #set up the headers
  4.     headers = CaseInsensitiveDict()
  5.     headers["Authorization"] = f"Bearer {authKey}"
  6.     headers["Client-Id"] = f"{clientId}"
  7.  
  8.     #make the request
  9.     resp = requests.get(f'https://api.twitch.tv/helix/{request}', headers=headers)
  10.  
  11.     #convert to python dict
  12.     return json.loads(resp.text)
  13.  
  14.  
  15. def main():
  16.     #load secrets
  17.     with open('secrets', 'r') as f:keys=(f.readlines()[0].split())
  18.  
  19.     print(makeRequest(request='users?id=517462271', authKey=keys[0], clientId=keys[1]))
  20.  
  21.     print(makeRequest(request='follows?to_id=517462271', authKey=keys[0], clientId=keys[1]))
  22.  
  23. if __name__ == '__main__':
  24.     import requests, json
  25.     from tkinter import *
  26.     from requests.structures import CaseInsensitiveDict
  27.     main()
RAW Paste Data