Get stream key by token

import requests
import time

class Twitch:
def init(self, oauth: str):
self.oauth = oauth
self.headers = {
‘Authorization’: 'Bearer ’ + self.oauth,
}

def get_stream_key(self):
    client_id = requests.get('https://id.twitch.tv/oauth2/validate', headers=self.headers).json()['client_id']
    id = requests.get('https://id.twitch.tv/oauth2/validate', headers=self.headers).json()['user_id']
    headers = {
        'Authorization': 'Bearer ' + self.oauth,
        'Client-Id': client_id
    }
    qqq = requests.get('https://api.twitch.tv/helix/streams/key',
                       params={'broadcaster_id': id},
                       headers=headers).json()
    print(qqq)
    return qqq
    

        
def get_key():
    with open('tokens.txt', 'r') as f:
        tokens = f.read().splitlines()
    i = 1
    for token in tokens:
        try:
            stream_key = Twitch(token).get_stream_key()
            headers = {
            'Authorization': 'Bearer ' + token
            }
            print(str(i)+' ---- ' + requests.get('https://id.twitch.tv/oauth2/validate', headers=headers).json()['login'] + ' ----')
            print(stream_key)
            with open('stream_key.txt', 'a') as f:
                f.write(stream_key + f':push rtmp://live-ams.twitch.tv/app/{stream_key};'+ '\n')
        except Exception as e:
            print(e)
        time.sleep(1)
        i += 1
    input()
    input()
    input()

Twitch.get_key()