I want get video infos

You want to get the number of viewers for a streamer video. However, it does not work with the following error message.

{‘error’: ‘Unauthorized’, ‘status’: 401, ‘message’: ‘OAuth token is missing’}

I’m using Python, and I already got the OAuth token with “analytics:read:extensions”.

The code is as follows
Hope you can help.

import requests
import json
import pandas as pd
import csv

client_id = "MY-Client-ID"
token = "MY-TOKEN"

video_id = "xxxx"
url = 'https://api.twitch.tv/helix/' + \
        "videos?id=" + video_id
headers = {'Client-ID': client_id,
               "Authorization": "Bearer" + token}
r = requests.get(url, headers=headers)
row_data = r.json()

I am using a translation from Japan. I hope it will be understood.

You simply missed a space ( ) after the word “Bearer” - so simply change "Bearer" + token to "Bearer " + token and it should work!

単純に、"Bearer "という単語の後にスペース( ) を入れていないだけです。従って、単純に "Bearer" + token"Bearer " + token に変更すれば、うまくいきます。

I appreciate it! For three hours, I suffered from this blank. :frowning:

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