Invalid get index 'data' on function "connect_to_eventsub" #20

Closed
opened 2023-03-03 01:47:37 +01:00 by tonebacas · 1 comment
tonebacas commented 2023-03-03 01:47:37 +01:00 (Migrated from github.com)

In file addons/gift/gift_node.gd, on line 454 (last line of the following snippet, function connect_to_eventsub)

add_child(request)
request.request("https://api.twitch.tv/helix/eventsub/subscriptions", ["User-Agent: GIFT/3.0.0 (Godot Engine)", "Authorization: Bearer " + token["access_token"], "Client-Id:" + client_id, "Content-Type: application/json"], HTTPClient.METHOD_POST, JSON.stringify(data))
var reply : Array = await(request.request_completed)
var response : Dictionary = JSON.parse_string(reply[3].get_string_from_utf8())
print("Now listening to %s events for broadcaster_id %s." % [response["data"][0]["type"], response["data"][0]["condition"]["broadcaster_user_id"]])

I get Invalid get index 'data' (on base: 'Dictionary').
The response was to the request was { "error": "Forbidden", "status": 403, "message": "subscription missing proper authorization" }, which does not have the data key, which causes the error.

Also, this code assumes the EventSub subscription process always succeeds, and does not handle any other outcome, which is problematic.

In file `addons/gift/gift_node.gd`, on line 454 (last line of the following snippet, function `connect_to_eventsub`) ``` add_child(request) request.request("https://api.twitch.tv/helix/eventsub/subscriptions", ["User-Agent: GIFT/3.0.0 (Godot Engine)", "Authorization: Bearer " + token["access_token"], "Client-Id:" + client_id, "Content-Type: application/json"], HTTPClient.METHOD_POST, JSON.stringify(data)) var reply : Array = await(request.request_completed) var response : Dictionary = JSON.parse_string(reply[3].get_string_from_utf8()) print("Now listening to %s events for broadcaster_id %s." % [response["data"][0]["type"], response["data"][0]["condition"]["broadcaster_user_id"]]) ``` I get `Invalid get index 'data' (on base: 'Dictionary')`. The response was to the request was `{ "error": "Forbidden", "status": 403, "message": "subscription missing proper authorization" }`, which does not have the `data` key, which causes the error. Also, this code assumes the EventSub subscription process always succeeds, and does not handle any other outcome, which is problematic.
issork commented 2023-03-03 16:08:59 +01:00 (Migrated from github.com)

Twitch changed the API regarding the channel.follow event. I will put the event subscription in the hands of the user instead of handling all event versions by GIFT. There will only be a single 'event' signal with the type of event and data instead of a signal for each event.

Events will have to be subscribed to by specifying the event name, API version and conditions and emit all related data, which will not require me to update GIFT on every API change in the future.

Will add a check for failure of the subscription as well, I simply forgot <3

Thanks!

Twitch changed the API regarding the channel.follow event. I will put the event subscription in the hands of the user instead of handling all event versions by GIFT. There will only be a single 'event' signal with the type of event and data instead of a signal for each event. Events will have to be subscribed to by specifying the event name, API version and conditions and emit all related data, which will not require me to update GIFT on every API change in the future. Will add a check for failure of the subscription as well, I simply forgot <3 Thanks!
Sign in to join this conversation.
No description provided.