Finding the User_ID of a streamer for Get Custom Reward Redemption

I am trying to get the user_id of a streamer, a friend of mine that I am doing a twitch-discord application for. Right now I have my authorization loop set up, I can fetch the data about the channel, but I am not sure where exactly can I find their user_id, that could be used for Get Custom Reward Redemption. I

Use the “Get Users” API to convert from a name to an ID.

Or use the oAuth token on the users API to get the ID for that token

You can see in this implicit auth example

The user will authenticate. then the token is passed directly to the users API to get the user data for that token

I am using the OAuth client credentials flow, I will try and use the get_users API to get the user_id. I will report back if it works. I do think I will get to some followup questions at a later point, so let’s leave the thread open for now.

And wow, thanks for the extremely fast response, that is very appreciated!!!

That doesn’t represent a user.

And you need to have authenticated at least once as a user to get permission to read/write redemptions/rewards.

By this I assumed you meant you authenticated a user, not got a server to server token.

See also, this blog post on the duality of EventSub Tokens

If you have an app access token, then you’ll need to use Get Users with a login to convert that login to a user ID.

Didn’t know that, sorry, I am quite new to the twitch API so I am still kind of finding my way around it. I have worked out the implicit authentication once before so I will try and use that instead.

The implicit is only an example. As it works on GitHub without leaking a secret. So you could test it or look at the code. There is a regular oAuth example on my github as well

Generally you would use regular oAuth so you can get a token that you can refresh for the user

Ok, let me preface this by saying that I normally do scientific computing, nothing to do with requests or APIs. I am a bit confused about the whole information flow here.

The way that I wanted my program to work is that I run it, it creates a custom reward on a specified channel, and then a separate program (a discord bot) watches for anyone redeeming that reward so that it can do some followup actions. (give a discord role for a dedicated viewer, specifically). I am now absolutely lost on where what authentication is actually needed. I thought the server-server was enough, but I understand that it would be really dangerous since I could just do this without the permission of the streamer in question. So, considering my presumed functioning in bold, what is it that I am missing? I apologize for posing questions that might be very basic, as mentioned, this is not my area of expertise.

In order to create a reward

you will need a user access token, a token that represents a user

You will also need to request the channel:manage:redemptions scope/permission

This oAuth flow will give you a token that represents the user.

You can then use this token with Get Users

To get the UserID of that token.

Then you can create and manage your reward(s) on that users channel.

I’m assuming you will use EventSub for this.

Event Sub ONLY uses App Access Tokens.

The Event Sub topic is

This topic, first requires the user to have granted access between the user and your ClientID using the User Access Flow (either regular as linked above in this post, or implict which I gave an example to earlier) with either the scope

  • channel:read:redemptions
  • channel:manage:redemptions

But since the user already authentcated earlier to allow you to create a reward with the channel:manage:redemptions scope, we already did this step.

EventSub will take the app access token you create the subscription with, confirm the clientID then see if the clientID has a connection to the requested user.

SO, TLDR, user logs in to the application as themself with the required scope.
You check if your reward exists and creates it if needed, using the user token
At the same time check/create your eventsub subscriptions for the reward add topic, using the app token.

That is the loooooong version

1 Like

That is amazing, sir, thank you so much! Never have I ever seen such support anywhere. I will get to work now! Have a great day and thank you once again!

1 Like

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