Get stream key by token

I got by authentification - user id, client_id
Then i am trying to get by helix method, in broadcaster id i set user id.
But i got 404

Sure you are calling

Correctly as documented?

headers = {
"Authentification": "Bearer token", 
"Client_id": client_id} 
stream_key = requests.get('', params = {'broadcaster_id': user_id}, headers=headers).json()


Yes sure, i use that link, i am from phone typed code

Others ideas why it doesnt work

Log the exact request you’re making, as a 404 would indicate you’re URL is incorrect. If you also log the body of the response and not just the status code that should also give you the full error.

I will paste, when i am at home

check my code

There is nothing obviously wrong from your screenshot

And I cannot copy and paste from the screenshot to test it in python

import requests
import time

class Twitch:
def init(self, oauth: str):
self.oauth = oauth
self.headers = {
‘Authorization’: 'Bearer ’ + self.oauth,

def get_stream_key(self):
    client_id = requests.get('', headers=self.headers).json()['client_id']
    id = requests.get('', headers=self.headers).json()['user_id']
    headers = {
        'Authorization': 'Bearer ' + self.oauth,
        'Client-Id': client_id
    qqq = requests.get('',
                       params={'broadcaster_id': id},
    return qqq

def get_key():
    with open('tokens.txt', 'r') as f:
        tokens =
    i = 1
    for token in tokens:
            stream_key = Twitch(token).get_stream_key()
            headers = {
            'Authorization': 'Bearer ' + token
            print(str(i)+' ---- ' + requests.get('', headers=headers).json()['login'] + ' ----')
            with open('stream_key.txt', 'a') as f:
                f.write(stream_key + f':push rtmp://{stream_key};'+ '\n')
        except Exception as e:
        i += 1


I distilled your code down to

import requests

oauth = 'TESTTOKEN';

headers = {
    'Authorization': 'Bearer ' + oauth

client_id = requests.get('', headers=headers).json()['client_id']
id = requests.get('', headers=headers).json()['user_id']
headers = {
    'Authorization': 'Bearer ' + oauth,
    'Client-Id': client_id
qqq = requests.get('',
                   params={'broadcaster_id': id},

And I was able to obtain a stream key.


I cannot find a problem with your code. No 404 was returned and my stream key was obtained

Thank you

i dont understand really, what happens

Looks like some some of environemental issue running the code your side.

There doesn’t seem to be anything incorrect

but 2 first requests is going to be OK, why the last one give this …

No idea. thats up to you to debug whats wrong with your environment, routing or something else.

The first calls are to the second to clutching at straws: did you hostfile somewhere else and it’s 404’ing since it’s not actually going to Twitch?

The problem needs to be traceed with/from your machine, as the code works fine on my machine

I was trying on dedicated server, what python version do u have?


But the version should be irrelevant since this wouldn’t cause a 404