core: Twitch Integration uses API not available to new users

The problem

I was trying to add a Twitch sensor, but kept getting the error ‘Client ID or OAuth token is not valid’ even though I was confident that my Client ID was valid. I downloaded the twitch-cli to verify that the client/token I was using were valid, they were. I looked at the integration source and noticed that the error text I was getting was just a catch all for response errors so tried to duplicate the call and see if I could find anything more helpful.

Querying the API manually results in this message: {“error”:“Not Found”,“status”:404,“message”:“The v5 API is deprecated and will be shutdown on February 28, 2022. Applications that have not accessed v5 before July 15, 2021 no longer have access to v5. For more information on the v5 API shutdown plan, see https://blog.twitch.tv/2021/07/15/legacy-twitch-api-v5-shutdown-details-and-timeline/ and the Twitch API documentation at https://dev.twitch.tv/docs/api.”}

I created my client_id today which tracks with the error message, and found another user in the discord who may have run into this issue at the end of last month. So my understanding is that existing users have another 6 months to use the integration, but new users will just run into errors until the integration is updated to the new API.

What is version of Home Assistant Core has the issue?

core-2021.6.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

twitch

Link to integration documentation on our website

https://www.home-assistant.io/integrations/twitch/

Example YAML snippet

sensor:
  - platform: twitch
    client_id: !secret twitch_id
    token: !secret twitch_secret
    channels:
      - Drzzs
      - BeardedTinker

Anything in the logs that might be useful for us?

Logger: homeassistant.components.twitch.sensor
Source: components/twitch/sensor.py:50
Integration: twitch (documentation, issues)
First occurred: 2:30:05 AM (1 occurrences)
Last logged: 2:30:05 AM

Client ID or OAuth token is not valid

Additional information

https://blog.twitch.tv/en/2021/07/15/legacy-twitch-api-v5-shutdown-details-and-timeline/

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 5
  • Comments: 22 (1 by maintainers)

Most upvoted comments

I’m new to Home Assistant and had the same issue. I found out you can create your own custom components and made a version of this that uses the Helix API. It works mostly the same way but the configuration has some slight changes.

I’ve put it up here: https://github.com/Radioh/ha_twitch_helix

This has still not been fixed. It should not be marked stale.

Could we get an alert created for this integration while this issue is open?

I think that this is going to very rapidly either need to be updated or it’ll stop working overall. I just got the below email:

Today, February 7, 2022, was the first temporary outage as we approach the final service shutdown on February 28, 2022. In order to not be affected by these outages or the shutdown, you will need to migrate to the latest Twitch API endpoints or remove functionality that will no longer be available. To help with the transition, we have provided a migration guide with endpoint and scope equivalencies.

I’m switching to Radioh’s custom integration since it doesn’t seem like this integration has any active maintainers. The underlying library (python-twitch-client) is now at v0.7.1 and theoretically supports the new Helix API, but the Helix API usage is different.

I recently received the same message from twitch. @Radioh, have you considered making a PR against HA Core to update the core integration? Depending on how drastic the change is, you might be able to get it in to 2021.12 or 2022.1.

Also not working for me, same issue as everyone else. Version 2022.2.2

Wanted to set up twitch integration on the latest 2022.2 version and it still gives the same error

@Icexist - It’s a good idea. But even though the custom component is heavily inspired by the core component I think it needs more work for it to even be considered as a part of the official repository. I’m not sure how high it has to be rated on this scale https://developers.home-assistant.io/docs/integration_quality_scale_index/, but I would assume it would be pretty high. 😃