Gunsmithy / TwitchLiveNotifier

Python script to notify a Discord server when the streamer goes live, with the current game and box art.
GNU General Public License v3.0
16 stars 11 forks source link

New Authentication at Twitch API needed #4

Closed schrotle closed 4 years ago

Gunsmithy commented 4 years ago

I'll work on this tonight! Already made the change for other code packages of mine. :)

schrotle commented 4 years ago

Cool thanks for you fast reply. I tried to figure it out on myself, which i obviously couldnt. :D

Gunsmithy commented 4 years ago

Going to have to take some more time with this. Not the same change that was required for their Websockets/IRC auth changes. Looks like it will have to authorize with your/the users' Twitch account. I'll let you know when it's done!

Gunsmithy commented 4 years ago

Well I got something basic started for doing the Twitch implicit OAuth flow, but then realized it would require you to authorize the application every few hours to keep working, which is of course no good. Looks like this app can no longer solely exist as a standalone client without exposing my Twitch API secret key, or users having to create their own developer accounts. As a result, I will have to stand up a web server to do the initial authorization code flow. This will obviously take much longer to do, but hey, I already have a Docker server and no plans for the weekend so we'll see. :)

schrotle commented 4 years ago

Making an own Twitch API isnt that hard right? You just create an Application where you get your ClientID and your Secret. Am I right? Im new to TwitchAPI so tell me if I am wrong. Thanks for your work, I appreciate it.

Gunsmithy commented 4 years ago

Hey there! Long time no speak.
Sorry for all the delay, it's been hectic over here. First a hard drive in my NAS died then I've been busy with work and stuff, but I finally made the change!
It gave me some time to think about your suggestion and I ended up going with that. You now need to register an application in the Twitch Developers console, but that is quite easy to do and overall a better user experience I would say than an authorize page probably every hour. Check it out on the Releases tab and let me know that it works for you before I resolve this. :)

schrotle commented 4 years ago

Hey man, I made it work for myself and I looked at your code to see how you done it. Seems good so far. One thing I couldnt find was code, that refreshes the Auth token after it expires. Im pretty sure you cant just make a new auth token. It didnt work for me last time I tried. Clear me up if im wrong.^^

schrotle commented 4 years ago

Ah i saw that your requested access token is one that expires in 60 days. I had a different one, that expired within a few hours and i had to refresh it with an refresh Token. But yours is way better. Thanks

Gunsmithy commented 4 years ago

Well I'm glad you got it working for yourself while I dragged my heels!
Yeah, the implicit token flow requires frequent refreshing, but the app access token method which is meant for server to server (which I think fits in this case since I'm not really vending a client to anyone anymore, they require their own credentials) is 60 days, you're right. Even if it happens to expire, it should re-auth with my code.
If this works well for you then I shall resolve this.