make twitch actually work frfr no cap

This commit is contained in:
Lera Elvoé 2023-12-10 16:23:50 +03:00
parent 2bd48d993b
commit e0239dcae0
No known key found for this signature in database
2 changed files with 12 additions and 4 deletions

View file

@ -10,7 +10,7 @@ signal token_received(token : String)
@export var client_id := "qyjg1mtby1ycs5scm1pvctos7yvyc1"
@export var redirect_uri := "http://localhost"
## Port that the redirect_uri will head to on your local system. Defaults to 80 for most cases. Linux tends to prefer 8000 or possibly 1338
@export var redirect_port := "80"
@export var redirect_port := "8000"
var twitch_url := "https://id.twitch.tv/oauth2/authorize?response_type=token&"
@ -86,7 +86,11 @@ func create_auth_url(scopes : Array[String] = ["chat:read", "chat:edit"], port :
str_scopes += " " + all
str_scopes = str_scopes.strip_edges()
var url = twitch_url + "client_id=" + id + "&redirect_uri=" + redirect + ":" + port + "&scope=" + str_scopes + "&state=" + str(state)
var full_redirect_uri := redirect
if !port.is_empty():
full_redirect_uri += ":" + port
var url = twitch_url + "client_id=" + id + "&redirect_uri=" + full_redirect_uri + "&scope=" + str_scopes + "&state=" + str(state)
return url
@ -104,7 +108,12 @@ func check_auth_peer(peer : StreamPeerTCP):
var info = peer.get_utf8_string(peer.get_available_bytes())
printraw(info)
var script = "<script>fetch('http://localhost/' + window.location.hash.substr(1))</script>"
var root := redirect_uri
if !redirect_port.is_empty():
root += ":" + redirect_port
root += "/"
var script = "<script>fetch('" + root + "' + window.location.hash.substr(1))</script>"
peer.put_data(str("HTTP/1.1 200\n\n" + script).to_utf8_buffer())

View file

@ -151,7 +151,6 @@ unique_name_in_owner = true
script = ExtResource("5_3n36q")
[node name="OBSWebsocketSetupDialog" parent="." instance=ExtResource("5_uo2gj")]
visible = false
[node name="Twitch_Setup_Dialog" parent="." instance=ExtResource("7_7rhap")]
visible = false