Get live status of a channel

Hi everyone,
I’m currently trying to get the live status of a channel.
To do so, I’m using the API endpoint

https://api.twitch.tv/helix/streams?user_id=ChannelName

with my client ID in the header

Client-ID: MyClientID

but I can’t since the API asks me an OAuth token

{“error”:“Unauthorized”,“status”:401,“message”:“OAuth token is missing”}

And this is where I don’t understand. I saw a topic where the user was getting a response without OAuth token.

Maybe should I use webhooks instead of the API ?
Can someone help me please ? thanks ^^

You require an oAuth token now to utilize the API

Thanks for answering so quickly :slight_smile:

I tried to generate a token for my app, but it always fails.
I want to use the API for a Discord Bot, but without OAuth token I can’t do anything.

I actually don’t know what to enter in the redirect_uri. I tried http://localhost, but it doesn’t seem to work

https://id.twitch.tv/oauth2/authorize?response_type=token&client_id=MyClientId&redirect_uri=http://localhost

First you need to decided what kind of token you want.

For stream status in a Discord bot, you probably want an app access token

I get this response

{
“access_token”: “MyToken”,
“expires_in”: 5075685,
“token_type”: “bearer”
}

Is the access_token the Oauth token I need ?

Yup

Add a header so you send

Client-ID MyClientID
Authorization: Bearer ACCESSTOKEN

Thank you very much :smiley: you were very helpful

Can I generate a new token every day or it’s too much ?

expires_in is in seconds, so you can renew it any point up to that point, or wait for it to die and then make a new one.

It’s around 60 days

Thank you very much, I’m now able to improve my bot ^^

1 Like

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