Getting Unauthorized Error

    def check_sub(self, nick, client_id, client_secret):

    #Get access token, works fine
    URL = "https://api.twitch.tv/kraken/oauth2/token?client_id="+client_id+"&client_secret="+client_secret+"&grant_type=client_credentials&scope=channel_subscriptions"
    resp = requests.post(URL)
    access_token = (json.loads(resp.text))["access_token"]

    #Send access token in my request in order to receive sublist
    URL = "https://api.twitch.tv/kraken/channels/"+self.USER_ID+"/subscriptions"
    params = {"Client-ID" : ""+ client_id +"",
            "Authorization" : "OAuth "+access_token+""
            }
    resp = requests.get(url=URL, headers=params)

What’s wrong in my code? Second request returns Unauthorized error.

You need a user access token to access a user’s/channel’s auth-gated resources. You seem to be using an app access token.

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