OAuth token not recognized

I am unable to make API calls.
I get the response that I need to provide an ID, Login or OAuth Token. I tried providing only the ClientID, only the OAuth Token, and both.

The relevant bits of my Code:

    def buildAuthHeader(self):
        if self.token == None:
            self.getToken()
        b = "Bearer " + self.token
        header = {
            "Client-ID": self.client_data["client_id"],
            "Authorization": b
            }
        return header

    def getStream(self, streamer):
        endpoint = "https://api.twitch.tv/helix/users?" + streamer
        header = self.buildAuthHeader()
        r = requests.get(endpoint, headers=header)
        print (r.text)

What am I missing here?

This looks correct.

Whats the error message you are getting from the API?

{"error":"Bad Request","status":400,"message":"Must provide an ID, Login or OAuth Token."}

The error is in your URL

endpoint = "https://api.twitch.tv/helix/users?" + streamer

Should be, if you have a username to lookup

endpoint = "https://api.twitch.tv/helix/users?login=" + streamer

or if you have a username to look up

endpoint = "https://api.twitch.tv/helix/users?id=" + streamer

or if you have a user access token and what the user

    endpoint = "https://api.twitch.tv/helix/users"

Oh, right…

Thank you for the incredibly quick support!

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