Another {'error': 'Unauthorized', 'status': 401, 'message': 'Missing User OAUTH Token'} post

I have read through All 43 posts, and i tried to employ each of the debugging steps. I am clearly doing something wrong, But i do not know where.

I am generating my oauth using this in python:

path="https://id.twitch.tv/oauth2/token?client_id={}&client_secret={}&grant_type=client_credentials&scope=channel:read:redemptions".format(clientID,secret)
response= requests.post(path)
self.oauth=response.json()["access_token"]

self.redemptionHeadder={}
self.redemptionHeadder["Client-Id"] = self.clientID
self.redemptionHeadder["Authorization"]="Bearer {}".format(self.oauth)

Next i validate my tokens with:

path='https://id.twitch.tv/oauth2/validate'
response  = requests.get(path, headers=self.redemptionHeadder)

It returns

{'client_id': <client id removed>, 'scopes': ['channel:read:redemptions'], 'expires_in': 5531017}

I then request the custom redeems list via

path="https://api.twitch.tv/helix/channel_points/custom_rewards?broadcaster_id={}".format(self.broacast_id)
response = requests.get(path, headers=self.redemptionHeadder)
data = response.json()

It returns the 401 but when i run the http debugger i get this:

GET /helix/channel_points/custom_rewards?broadcaster_id=141039735 HTTP/1.1\r\nHost: api.twitch.tv\r\nUser-Agent: python-requests/2.24.0\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nClient-Id: <removed Clien ID>\r\nAuthorization: Bearer <removed oauth key>\r\n\r\n

You have the wrong token type, you generated an app access token aka Server to Server token. This is a “server token” and as the error says you need a “user token”

You need a user access token.

An App access token doesn’t represent a user (and essentially can earn no useful scopes)

A grant_type=code not a grant_type=client_credentials, will will also need an oAuth loop since you need some webservery bits to run this flow (to recieve HTTP Get requests)

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