Hello. I am trying to do a Telegram Bot to let enter in a group only the subscribers to a specific streamer. I started to write a python script to get oauth token and get the list of subs that a user has.
Never, ever, leak tokens, tokens are like passwords and you should not leak them
You did the first step of user oAuth, threw it out and then got a server to server token instead. (Client credentials)
So in fact you generated a client_credentials token
Such a token doesn’t represent a user, hence the error
See step 3
You are supposed to take the ?code in the URL when the user comes back to your app from Twitch and exchange it for a token.
In our example, your user gets redirected to:
3) On your server, get an access token by making this request:
?client_id=<your client ID>
&client_secret=<your client secret>
&code=<authorization code received above>
&redirect_uri=<your registered redirect URI>
token_id = getToken(code) #this take the code of ?code=something page and extract the value of "access_token"
headers= getHeader(token_id) #generate the headers below
user_id= getUserInfo(token_id,headers) #this return my correct id (i am testing on myself)
####until here all ok
subs = getSubs(headers,user_id)
return requests.get(link,headers = headers).json()