Get Channel ID by Authorization token

Is there a way to get the Channel ID of the account’s authorization token?
Authorization is otherwise known as OAuth,

Call the Users endpoint

Without specifying a userID or login.
A user is also a broadcaster, different labels are used depending on the endpoint being discussed

The example from the documenation is

curl -H 'Client-ID: yourClientID' \
-H 'Authorization: Bearer cfabdegwdoklmawdzdo98xt2fo512y' \
-X GET 'https://api.twitch.tv/helix/users?id=44322889'

But if you do

curl -H 'Client-ID: yourClientID' \
-H 'Authorization: Bearer cfabdegwdoklmawdzdo98xt2fo512y' \
-X GET 'https://api.twitch.tv/helix/users'

You’ll get the user JSON for that Token and can extract the ID from that.

Edit: note the examples are invalid due to the Helix API changes and I just went and lifted then from the docs
Edit 2: fixed the calls

Thank you for the fast reply, I’ll try that now.

I got a response: {“error”:“Unauthorized”,“status”:401,“message”:“Client ID and OAuth token do not match”}

Then the ClientID and oAuth token don’t match and you need to specify the matching keys

I’m not mentioned a Client-ID of any sort in this, here’s the code:
OAuth = line.strip(’\n’).split(’:’)[-1]

        #print(line)

        GetChannelID = requests.get('https://api.twitch.tv/helix/users', headers={'Authorization': 'Bearer ' + str(line)}).text

        print(GetChannelID)

You didn’t specify a client-id.

I copied the examples from the docs exactly, and the docs have an error. Should be

curl -H 'Client-ID: yourClientID' \
-H 'Authorization: Bearer YourAccessToken' \
-X GET 'https://api.twitch.tv/helix/users'

I see, I just copied the example you wrote. Thanks I’ll retry.

It works. thank you.

Last thing, is there a ratelimit on this?

Helix is rate limited to 800 calls / minute as documented

1 Like

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