Skip to content

Fixes unsetup for proper twitch disconnection - #79

Merged
kanimaru merged 2 commits into
kanimaru:masterfrom
TooPixelTV:master
Oct 15, 2025
Merged

Fixes unsetup for proper twitch disconnection#79
kanimaru merged 2 commits into
kanimaru:masterfrom
TooPixelTV:master

Conversation

@TooPixelTV

Copy link
Copy Markdown
Contributor

Hi !

Thanks for your add-on, it really helps me to add twitch interactions to my games without redoing the same boring twitch auth again and again ^^

I've done some modifications to be able to disconnect from the currently connected Twitch account (I have a bot account and a main twitch account, so I wanted to be able to switch easily from one to the other).

I mainly added some unsetup steps and also fix some errors that came while unsubscribing eventsubs.

I mainly use public client type with implicit flow and did not try other type of authorizations, so I hope it has no side effects for them.

@kanimaru kanimaru left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But tbh. Implicit + Change for bot use seems unnesseccerily complicated. In the latest master I added a TwitchChatBot that helps you to setup chat stuff with an 2. bot account. Maybe this would solve your issue. Also I recommend using auth code flow instead of implicit.
I only support implicit to be fully Twitch compatible, but this flow is deprecated and has security issues by design.

Nevertheless the changes to unsetup stuff correctly looks fine. Also good catch on the eventsub unsubscribe. Didn't had this one on the radar!

Comment on lines +294 to +297
if response == null:
return false
else:
return response.error || response.response_code != 200

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary, I fixed the issue in the latest Master Commit. Response should never be null anymore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've removed this part in my new commit

Comment thread addons/twitcher/lib/http/http_server.gd Outdated
HTTPServer.logError("Could not poll client %d: %s" % [_port, error_string(error)])
client_error_occured.emit(client, error)
elif peer.get_available_bytes() > 0:
elif peer.get_status() == StreamPeerTCP.STATUS_CONNECTED and peer.get_available_bytes() > 0:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this one why you need to check for connected at this point? it is already checked in line 76.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated this part in my new commit.

I originally made this change here because each time I connect to Twitch I have this error in my debugger.

image

After some researches, I updated my code. It seems that the peer.poll() can itself close the connection and return OK because it's not an error, it's just the fact that there is no more data to poll.

@TooPixelTV

Copy link
Copy Markdown
Contributor Author

Made some changes according to your comments.

I will try the auth code flow as you suggested, to see if it fits my need, but for now, with my changes the implicit flow works nicely without errors even if I login and logout again and again.

@TooPixelTV
TooPixelTV requested a review from kanimaru October 15, 2025 08:07

@kanimaru kanimaru left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes

@kanimaru
kanimaru merged commit f2ca8ce into kanimaru:master Oct 15, 2025
@kanimaru

Copy link
Copy Markdown
Owner

And the difference between Auth and Implicit. In Implicit you getting your token via Anchor parameter that theoretically can be stolen on the way to you cause the URL isn't encrypted in an HTTPS environment and proxies / vpns etc could log it.
In the Auth Code Scenario you get just a Code that you can use with your secret to fetch your accesstoken from the /token endpoint (fully automated in Twitcher)

The implicit flow was made for websites without a backend that handles the auth for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants