Set stream title and game in Python

I don’t understand, what am I doing wrong?

url = ""

headers = {"Client-ID" : ""+ config.CLIENT_ID +"", "Authorization": "OAuth "+config.CHAN_OAUTH}
data = {"channel": {"status": "The Finalest of Fantasies"}}

response = requests.put(url=url, headers=headers, params = data)

I’m getting a 401 response error for (apparently) no reason.

Does your OAuth token have the channel_editor scope?

I didn’t think about that, so probably it doesn’t. How can I fix that?

Request it using one of the user access token flows:

So, I need to act like this:

url = ""
params = {"Client-ID" : ""+ config.CLIENT_ID +"", "scope" : "channel_editor"}
config.resp = requests.get(url=url, headers=params)

Before setting the status as I was doing before.
Am I right?

@Pinasu - First of all, what version are you trying to use? v3, v5 or the new twitch API?

Since you wrote

It looks like its v3 or v5.

But you haven’t specified which version.

You solve a lot of obfuscated problems by setting API version.

It also dictates the authentication process.

Which doc are you following?

I’m using v5, so I’m getting all my infos from here.

Looks like this end point

That’s right, but I was getting Error 401.

To update other parameters: channel_editor

So I was trying to get the right token as @george suggested.

First of all, you need to add api_version=5 to your URL in that case, I think.
Or apply the header application/vnd.twitchtv.v5+json header, as described here:

Also found:

401 Unauthorized. The OAuth token does not have the correct scope or does not have the required permission on behalf of the specified user

And @george is right you need channel_editor as described here:

channel_editor Write channel metadata (game, status, etc).

But you still gettng 401?

Since its from Python, you using app access tokens?

I just added the API version in the header and I’m trying to get the right token as follows:

url = ""
params = {"Client-ID" : ""+ config.CLIENT_ID +"",
          "Accept" : "application/vnd.twitchtv.v5+json", 
          "scope" : "openid channel_editor"}
config.resp = requests.get(url=url, headers=params)

But I’m getting “Bad request”, so I’m probably miswriting something.

Is scope a header? I thought it was an URL query parameter. Hm.

Also which “Procedure” you using?

I’m using the OIDC Authorization Code Flow (ID Tokens and User Access Tokens) one.
Setting the scope as parameter still gives me 400 Bad request.

EDIT: I’m missing the redirect URI, so that’s probably my issue. I really don’t remember what was my URL when I registered my app, so I’m trying to figure out how to get that.

I think its found here, for your app:

Yes I already found it, thanks anyway.

Setting the redirect uri as header param seemed to be the trick, so I’m now able to receive the 200 code from the token request. Now I don’t understand what am I supposed to do after obtaining my

EDIT: from what I read, I need to send a new request with the “client_secret” code, sent me from the server.

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