[Question] What's the best way to know whether the user is Broadcaster or Viewer?


I’m totally new in this, I have been checking the Hello world example and I think I get most of the concepts in Extensions.
But I’m not sure which is the best way to identify whether the current user is the broadcaster or the viewer. I though that’s something I would get with the context or the authorisation, but that’s not the case, and I’m not sure if I should make a call to /user in the backend or if there’s a better way!

Thanks :slight_smile:

As documented:


returns userID (Opaque user ID.)


Broadcasters’ tokens are set with "U" + their Twitch user IDs, to avoid confusing opaque IDs with user IDs when the broadcaster is a viewer.

If that helps.

Or onAuthorized parse the response (don’t validate) and test the role key

But for that I would need to decode the JWT which can only happen in the EBS, I was looking for a way to do this without the need of a EBS at all :frowning:


You can parse/decode the JWT client side.

Split the JWT around . (periods).

The first part is the alogirthm, the second is the data (as a JSON object) and the third is the validator. If you don’t care about validation, you can parse/decode client side and read the data and skip validation. Course don’t do that for something where you need it to be valid, but saves me a lookup to see if the user has shared their ID.

Or just test the OpaqueID for being of the form of “broadcaster”

Ah, that’s true. Thanks!
I think I need to use some sort of BE anyway, so I think I’ll do this there - but this might be useful in other scenarios

Many thanks!