Teekeks / pyTwitchAPI

A Python 3.7 compatible implementation of the Twitch API, EventSub, PubSub and Chat
https://pytwitchapi.dev
MIT License
254 stars 38 forks source link

Is it possible to handle webhook requests using django redirections (without built-in aiohttp.web server) ? #236

Closed RduMarais closed 1 year ago

RduMarais commented 1 year ago

Hi all,

I am making a django application using pyTwitchAPI. I am trying to use EventSub, but from what I understand, the constructor creates a new server thread with aiohttp.web.Application.

Is there a way to handle incoming request for event sub using my - already functioning - Django App ? The reason for this are :

Do I have to use aiohttp.web.Application and open a port ? Or can I call primitives of the eventsub class from a URL defined in django ?

Sorry for this quite django-specific question. If there is no simple way around, any help would be greatly appreciated !

Thanks a lot

stolenvw commented 1 year ago

The authenticate function does not start the webserver if you give it a user auth token, there is a function to return an auth url that you can use then have Django get the user auth token and send that I'd to the authenticate function to get the tokens

RduMarais commented 1 year ago

I reckon this is the case for the authentication when creating a twitchAPI.twitch.Twitch object, and I implemented my authentication and callbacks accordingly. But can I do the same for twitchAPI.eventsub.EventSub ? there should be no authentication going on in the EventSub, only the use of a token previously obtained, so I'm not sure that I understood your answer correctly

stolenvw commented 1 year ago

Yeah I totally miss read that, for eventsub I'm not sure of away around it for now, I know they are working on websockets for eventsub but don't know if that is out of beta yet

Teekeks commented 1 year ago

its not possible to do that at the moment, the websocket eventsub is also still in beta

RduMarais commented 1 year ago

Thansk, is there a way to only listen on localhost with the eventsub server then ?

Teekeks commented 1 year ago

yes, , the EventSub class has _host as a variable, setting that to 127.0.0.1 before calling .start() should do the trick. (I should really properly expose that var)

Teekeks commented 1 year ago

EventSub Websocket is now released and host of EventSub Webhook has been exposed.