Api auth error Invalid OAuth token

Could someone help me understand what would be the error of my code below? :

self.username = ‘’‘myusername’’’
self.channel = ‘’‘mychannelname’’’
self.app_client_id = ‘’‘xxxxxx’’’ #from https://dev.twitch.tv/console/apps
self.authorization = ‘’‘xxxxx’’’ #from http://twitchapps.com/tmi/

url = ‘https://api.twitch.tv/helix/search/channels?query=’ + self.channel
headers = {‘client-id’: self.app_client_id, ‘Authorization’: 'Bearer ’ + self.authorization}
r = requests.get(url, headers=headers).json()
self.channel_id = r[‘data’][0][‘id’]

function variables
‘message’:‘Invalid OAuth token’


assuming self.authorization is actually populated with the token

Then that would suggest the token is invalid

I took a new token and tried again, same return

is self.authorization actually populated when you pass it to that request?

I see you are also using the search endpoint

This python example might be of more use, it’ll generate an App Access Token and do a “is stream live” check instead.

And doesn’t rely on someone elses token generator

I did a test with your code and got the response below
{‘status’: 403, ‘message’: ‘invalid client secret’}

so there is a problem with my token, maybe need I use another link besides this one ? https://twitchapps.com/tmi/

Then you copy/pasted the client secret wrong from the dashboard.

ah I got it now, id and secret are from same url: https://dev.twitch.tv/console/apps.

It worked now, thanks !

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