# \[Python\] Change the stream title

**URL:** <https://discuss.dev.twitch.com/t/python-change-the-stream-title/24848>\
**Category:** API\
**Created:** [April 7, 2020, 8:39pm UTC](https://discuss.dev.twitch.com/t/python-change-the-stream-title/24848 "2020-04-07T20:39:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kikimora](https://avatars.discourse-cdn.com/v4/letter/k/c77e96/32.png) [@kikimora](https://discuss.dev.twitch.com/u/kikimora)\
**Post date:** [April 7, 2020, 8:39pm UTC](https://discuss.dev.twitch.com/t/python-change-the-stream-title/24848/1 "2020-04-07T20:39:50Z")

</div>

Hi. I apologize for my bad English.  
I am trying to make a command to change the title of a stream, but this fails. I gave the bot appropriate access (channel\_editor) and when I send the request, I get a 200 response, but the stream title still does not change.

I have already tried many ways that I myself have invented or found on the Internet, and now I have this code:

> url = “[https://api.twitch.tv/kraken/channels/](https://api.twitch.tv/kraken/channels/)” + CHANNEL\_ID  
> headers =   
> {  
> ‘Accept’: ‘application/vnd.twitchtv.v5+json’,  
> “Client-ID”: BOT\_CLIENT\_ID,  
> “Authorization”: "OAuth " + BOT\_OAUTH  
> }  
> data = ‘{“channel”: {“status”: “New Title”}}’  
> response = requests.put(url=url, headers=headers, params=data)  
> print(response) # \<Response [200]\>

What am I doing wrong?  
I would be very grateful if you provided an example of a working code (I do not know much English and the official twitch documentation is rather confusing for me when it comes to requests, but I could not find decent documentation in my native language).

---

<div class="post-metadata">

**Author:** ![kikimora](https://avatars.discourse-cdn.com/v4/letter/k/c77e96/32.png) [@kikimora](https://discuss.dev.twitch.com/u/kikimora)\
**Post date:** [April 11, 2020, 6:57pm UTC](https://discuss.dev.twitch.com/t/python-change-the-stream-title/24848/2 "2020-04-11T18:57:44Z")

</div>

This is resolved.

My mistake was that I generated a token with access on behalf of the bot, and not on behalf of my channel.

The working version of the code looks like this:

> ```
> url = "https://api.twitch.tv/kraken/channels/" + TWITCH_CHANNEL_ID
> headers = \
> {
> 'Accept': 'application/vnd.twitchtv.v5+json',
> "Client-ID": BOT_CLIENT_ID,
> "Authorization": "OAuth " + AUTH_TOKEN,
> "Content-Type": "application/json"
> }
> data = '{"channel": {"status":"New Title"}}'
> response = requests.put(url=url, headers=headers, data=data.encode('utf-8')).json()
> 
> ```

I’m repeat that for the query to work correctly, it is necessary to generate AUTH\_TOKEN on behalf of the streamer, the data of which needs to be changed, allowing access to “channel\_editor”, and not on behalf of the bot account.

And once again I apologize for my English =)  
Closed.

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [May 11, 2020, 6:57pm UTC](https://discuss.dev.twitch.com/t/python-change-the-stream-title/24848/3 "2020-05-11T18:57:47Z")

</div>

Closed on May 11, 2020, 6:57pm UTC

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