anxdpanic / plugin.video.twitch

Watch your favorite gaming streams on Kodi
https://twitchaddon.page.link/forum
270 stars 80 forks source link

Twitch fails to launch today with an api related error (or something is wrong with my api key) #653

Closed pitsi closed 2 years ago

pitsi commented 2 years ago

Context


Expected Behavior

Twitch and everything related to it (= some bookmarked channels I have) should launch as usual.


Current Behavior

As of today, twitch fails to launch on my end and a notification that says "connection failed, failed to connect to twitch api" comes up . Details from the log are shown below.


Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Make sure you have made an api key for twitch's new api and set it in the addons settings under login > oauth token.
  2. Launch twitch.
  3. Notice the notification.

Log

2022-04-27 07:19:57.678 T:4564    ERROR <general>: Traceback (most recent call last):
2022-04-27 07:19:57.678 T:4564    ERROR <general>: 
2022-04-27 07:19:57.678 T:4564    ERROR <general>:   File "/home/user/.kodi/addons/plugin.video.twitch/resources/lib/twitch_addon/router.py", line 290, in run
                                                       twitch_api = api.Twitch()
2022-04-27 07:19:57.679 T:4564    ERROR <general>: 
2022-04-27 07:19:57.679 T:4564    ERROR <general>:   File "/home/user/.kodi/addons/plugin.video.twitch/resources/lib/twitch_addon/addon/api.py", line 54, in __init__
                                                       if not self.valid_token(self.client_id, self.access_token, self.required_scopes):
2022-04-27 07:19:57.679 T:4564    ERROR <general>: 
2022-04-27 07:19:57.679 T:4564    ERROR <general>:   File "/home/user/.kodi/addons/plugin.video.twitch/resources/lib/twitch_addon/addon/common/cache.py", line 104, in memoizer
                                                       result = func(*args, **kwargs)
2022-04-27 07:19:57.679 T:4564    ERROR <general>: 
2022-04-27 07:19:57.679 T:4564    ERROR <general>:   File "/home/user/.kodi/addons/plugin.video.twitch/resources/lib/twitch_addon/addon/api.py", line 62, in valid_token
                                                       if token_check['client_id'] == self.client_id:
2022-04-27 07:19:57.679 T:4564    ERROR <general>: 
2022-04-27 07:19:57.679 T:4564    ERROR <general>: KeyError: 'client_id'
2022-04-27 07:19:57.679 T:4564    ERROR <general>: 
2022-04-27 07:19:57.679 T:4564    ERROR <general>: Twitch: None
2022-04-27 07:19:57.679 T:4564     INFO <general>: CPythonInvoker(6, /home/user/.kodi/addons/plugin.video.twitch/resources/lib/addon_runner.py): script successfully run

Additional Information

Because of python 3.10 that my distro is now using, kodi 19.4 sometimes crashes, so any log or troubleshooting attempt will be done on libreelec that is still on python2. The log above though is from that debian system. I also have twitch, with the same api key, on a libreelec 10.0.2 x64 and on a coreelec 9.2.8 (s905 tvbox) installation.


pitsi commented 2 years ago

And now it just gets stuck on the loading notification when I open it or select any of the bookmarks...

MeisterKnobi commented 2 years ago

Atm im not able to post a log but i have the same problem. LibreElec 9.2.6 Kodi 18.9 Twitch 2.6.0

Earlier today it has worked fine, streams got listed, notifications, ect., then without restart it asked for an new api token but the button dose not work anymore.

pitsi commented 2 years ago

Glad to see I am not the only one then, so I won't bother making a new key. On the other hand, if it is an issue of the api, why isn't there a freaking announcement in twitch's blog? Oh, the "connection failed, failed to connect to twitch api" notification is back.

apo86 commented 2 years ago

Unfortunately it looks like there is an issue with the "get token" function. It seems that it's trying to validate the expired token, errors out and then doesn't display the link to acquire a new one. Not sure what exactly happens there, I assume this is a bug that was introduced with the rework of the addon for the new twitch API. You can work around this by first removing the old token from the settings, before trying to get a new one. Then the button works / shows you the link you need.

If you still have issues afterwards, also check if your private api credentials (the optional one used for sub benefits) are still up to date or also need to be replaced.

MeisterKnobi commented 2 years ago

Unfortunately it looks like there is an issue with the "get token" function. It seems that it's trying to validate the expired token, errors out and then doesn't display the link to acquire a new one. Not sure what exactly happens there, I assume this is a bug that was introduced with the rework of the addon for the new twitch API. You can work around this by first removing the old token from the settings, before trying to get a new one. Then the button works / shows you the link you need.

If you still have issues afterwards, also check if your private api credentials (the optional one used for sub benefits) are still up to date or also need to be replaced.

Thank you! Worked for me!

pitsi commented 2 years ago

So, the api key, which became mandatory from twitch's end since ~2 months ago, expired and there was not a single notification neither inside the addon, nor from twitch itself (which I think is more expected)... Good work twitch! Shall I expect it to expire every 2 months now? That is why I absolutely HATE creating credentials for services that are otherwise free.

apo86 commented 2 years ago

Yeah, Twitch doesn't give a crap. Keep in mind API keys aren't intended for regular users and this isn't how you're supposed to consume streams as far as they are concerned. So key expiration is not something they would send you an email for or something.

The addon does tell you when the key is expired, just not in a way you could reasonably be expected to understand ;) I agree that this whole workflow around API usage, the GUI, error handling and error messages, etc. are all less than ideal. See also https://github.com/anxdpanic/plugin.video.twitch/issues/651 , add this one to the pile. But the problem is this project is essentially maintained by a single person, who I'm sure has more interesting and/or important things going on in their life. If there's small little things to fix then I try to support, but a rework of the login functionality is beyond my abilities.

anxdpanic commented 2 years ago

These token issues are on my radar, I have a few things that need my attention more at the moment. Happy to review anything, if anyone has time to address any of these issues.

pitsi commented 2 years ago

Yeah, Twitch doesn't give a crap. Keep in mind API keys aren't intended for regular users and this isn't how you're supposed to consume streams as far as they are concerned. So key expiration is not something they would send you an email for or something.

Well, fuck twitch then! Like youtube, it forced me (i.e. the average user) to create credentials in order to access the api and when it decided to disable the key(s), it send no notification back about the issue.

Please allow me a newbie question. Being new to twitch and the way it works, I noticed I have to enter a 6-digit code, which it sends on my email, every time I want to access my stuff, e.g. for creating the api key. Does it also have this type of 2 factor authentication for you too?

cmsimike commented 2 years ago

Just happened with me today! :( Is there a known work around? Can I regenerate any keys on my end to fix this up?

borzaka commented 2 years ago

Just happened with me today! :( Is there a known work around? Can I regenerate any keys on my end to fix this up?

Just follow the instuctions here: https://github.com/anxdpanic/plugin.video.twitch/issues/653#issuecomment-1111522046 Basically remove the old token, and generate a new one on the given link.

cmsimike commented 2 years ago

Just happened with me today! :( Is there a known work around? Can I regenerate any keys on my end to fix this up?

Just follow the instuctions here: #653 (comment) Basically remove the old token, and generate a new one on the given link.

Thank you! I somehow overlooked this when reviewing the issue. This worked perfectly.

rssblinded commented 2 years ago

The link for generate the api token is not working It says the dynamic link not found,looks like the developer must check ,ensure that the dynamic link domain is correctly configured ,that is the message on there

pitsi commented 2 years ago

Closing as fixed in 2.6.1. I have put my old key back on one installation and I will check how it will react once it gets the upgrade to 2.6.1, because it has not reached the main repo yet. A big thanks to anxdpanic for doing for us what twitch should have done, i.e. a simple notification that the key no longer works.

pitsi commented 2 years ago

Did anyone else get a message today that their key is invalid or am I the lucky one again? It is afternoon here, twitch was working with no issues this morning and I just got the message that it is invalid. I received no email and no notification from twitch's end, like last time, so now I am mad because this is the 2nd time it happens in 4 months!

apo86 commented 2 years ago

Not today specifically, but I think maybe last week if I remember correctly. Either way, this is going to be a regular thing. Nothing we can do except suck it up.

pitsi commented 2 years ago

Great... Is there a way to completely delete my twitch account? I will make a new key tomorrow, but if this keeps happening I will probably delete it and remove twitch from kodi after 5+ years :(

pitsi commented 2 years ago

I made a new key ~15 days after my post above. Yesterday marked exactly 2 months (July 7th to September 7th) that I had that key in use on my devices. And today, it just stopped working, just like the previous ones. As it seems every generated key has a 2-month life after which it is rendered completely useless. If anyone else has observed this behavior, please add that detail in the readme. In case there is any difference between account types, I am talking about a free account.

So, if the above is true, this means that from now on, the user must create a new key for the addon 6 times a year! Well... f@#% that new api then!