Trying to receive messages from chat continuously, but noticed that twitch disconnects me after approximately 10 min, so I created app here https://dev.twitch.tv/console/apps and got access_token by sending client_id and client_secret to id.twitch.tv/oauth2/token. After that I try to send pass and nick using socket but I receive :tmi.twitch.tv NOTICE * :Login unsuccessful
import socket
import requests
r = requests.post(f'https://id.twitch.tv/oauth2/token'
f'?client_id={CLIENT_ID}'
f'&client_secret={CLIENT_SECRET}'
f'&grant_type=client_credentials'
f'&scope=chat:read chat:edit channel:moderate')
resp = r.json()
PASS = resp['access_token']
s = socket.socket()
s.connect((Host, Port))
s.send(f"PASS oauth:{PASS}\r\n".encode("utf-8"))
s.send(f"NICK {Nickname.lower()}\r\n".encode("utf-8"))
s.send(f"JOIN {Channel}\r\n".encode("utf-8"))
while True:
rec = s.recv(1024).decode("utf-8")
print(rec)