Error 401 on request, Helix upadte?

Good morning, everyone.

Today I wanted to work on my Bot discord project in java and I’m querying the helix API, but I got the error:
{
“error”: “Unauthorized.”
"Status: 401,
“message”: “OAuth token is missing.”
}

Whereas 2 days ago everything worked and I haven’t changed my header since.

Here’s my request in Postman
https://api.twitch.tv/helix/streams?user_login=french_barttv
Answer:
{
“error”: “Unauthorized.”
"Status: 401,
“message”: “OAuth token is missing.”
}

2nd request:
https://api.twitch.tv/kraken/streams?user_login=skyyart
Answer:
{
“streams”: [
{
“id”: 38007097008,
“game”: “Dota 2”,
“broadcast_platform”: “live.”

}

The problem is that I am obliged to use the api helix because I use certain elements in the answer.

Is there anyone who can tell me why and if so, can you tell me how to do it?
Thank you

All helix requests require an oAuth token as of yesterday.

As the Error message you are getting states

You need to use an oAuth token with your request, most commonly you need an App Access Token aka Server to Server also know as “Client Credentials” token

Oh my goooodd :rofl:
I didn’t even think to look at it.

Thanks

@BarryCarlyon
I just made my request POST
I don’t understand what to put in grant_type.

My request :
https://id.twitch.tv/oauth2/token?client_id=lxc938tfzjwgmz9i7n1…&client_secret=…fx4h3avxnog6s1u&grant_type=client_credentials

Response :
{
“access_token”: “…”,
“expires_in”: 5286713,
“token_type”: “bearer”
}

As per the docs

For an App Access Token/server to server/Client Credentials token

Required Parameter Type Description
client_id string Your client ID.
client_secret string Your client secret.
grant_type string Must be client_credentials.

it must be client_credentials

I just don’t understand what client_credentials should be?

The grant type is client_credentials it’s literally the word client_credentials. Not sure what you mean by I just don’t understand what client_credentials should be? since the grant_type for The Client Credentials OAuth Flow is client_credentials

POST https://id.twitch.tv/oauth2/token
    ?client_id=<your client ID>
    &client_secret=<your client secret>
    &grant_type=client_credentials

Which’ll return JSON blob including an access_token

You then use that access_token in your header that already has the client-id in with your request to helix, as described in the announcment post I linked

So

https://api.twitch.tv/helix/streams?user_login=french_barttv
headers:
client-id: yourClientId
authorization: Bearer yourAccessToken

Where yourAccessToken is from the Client Credentials post

:face_with_symbols_over_mouth: I’m gonna throw myself off a bridge, I didn’t realize you had to put Bearer before his acces_token.

S’all good.

I’m sorry I bothered you. I thought my mistake was client_credentials.

s’all good no bother at all!

Why was this change made? This makes the helix API 100% more annoying to use…

There is no need to post the same question to multiple threads @simoniz0r

Details are in the linked announcment

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