Twitch: Client ID and OAuth token do not match

I’m trying to make a Discord bot that sends a notification if a specific streamer is live with a specific word in the title. When I tried to run the code I got the following error:

{'error': 'Unauthorized', 'status': 401, 'message': 'Client ID and OAuth token do not match'}

Here is the code:

import discord
import requests
import asyncio

intents = discord.Intents.default()
intents.guilds = True
intents.guild_messages = True

client = discord.Client(intents=intents)

client_id = 'CLIENT_ID'
access_token = 'ACCESS_TOKEN'
streamer_id = 'STREAMER_ID'

@client.event
async def on_ready():
    client.loop.create_task(run_stream_check())

async def check_stream():
    headers = {
        'Client-ID': client_id,
        'Authorization': f'Bearer {access_token}'
    }
    url = f'https://api.twitch.tv/helix/streams?user_id={streamer_id}'
    response = requests.get(url, headers=headers)
    print(response.json())
    data = response.json()
    if 'data' in data:
        if data['data']:
            if 'TEST' in data['data'][0]['title']:
                channel = client.get_channel(1057814763087872212)
                await channel.send('Streamer is live with TEST in the title')

async def run_stream_check():
    while True:
        await check_stream()
        await asyncio.sleep(300)

client.run('DISCORD_BOT_TOKEN')

I obviously replaced the placeholders in my python file.
I also tried to check if my access token works with “curl” and there it worked fine.

Then the client_id in this bit of code is not the client_id that was used to create the access_token

or you have in fact used you client secret instead of generating a token to use

Thank you, that worked! I accidentally used the client_id of another application.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.