How to get user ID of extension viewer?

Hello guys, my extension has been approved and released and after install, I found there is one problem in the extension. I install the extension on my channel so I’m getting my userId correct but when I visit my channel from a different account I’m not getting the userID correct. I am getting this “GSuXeFSQr_QsrsTToaLC” instead of getting viewer userId. I know I’m mistaking somewhere.
So in short, I want to get the userId/channel_id of viewer/visitor in my extension who visit my channel so I can fetch his record through an API and display in my extension. please help.

You need to extract the user ID from the JWT Schema.

Broadcasters are “auto allowed” to share their ID

That looks like an opaque user ID? Did you request the user ID from the user? If you’re testing with an account where you are the broadcaster and you access your own channel page, you will be given automatically your actual user ID in the JWT payload as Barry mentioned. In other words, you don’t have to request/share your own user ID, but you do for everyone else.

Another cross check is during the times you see an actual user ID, does the JWT payload show a role field with the value “broadcaster”, indicating the current user data in the payload belongs to the channel owner (i.e. - the broadcaster).

One point of interest. Are you seeing that user ID in the JWT payload user_id field or in the opaque_user_id field? I’ve only seen user IDs that are both letters and numbers in the opaque_user_id field. All the user_id field values I’ve seen are always numeric (so far), except for the “U” that prefixes them when used as a user ID instead of a channel ID.

It’s neither

  • Identifies the session using this JWT. Any token generated by your EBS should leave this field blank. When present, the value is interpreted as follows:
  • Values beginning with “U” are stable references to a Twitch account across sessions and channels. You can use them to provide persistent services to users.
  • Values beginning with “A” are transient references to an anonymous Twitch session; the user has not logged into the Twitch website. These values are not stable and should never be associated with persistent data. It is possible for them to represent different users over time. If your extension requires a stable user identity, your front-end interface should display an appropriate login request when this field does not begin with “U.”
  • Broadcasters’ tokens are set with “U” + their Twitch user IDs, to avoid confusing opaque IDs with user IDs when the broadcaster is a viewer.
1 Like

@BarryCarlyon @AssistWitch

thanks you lovelies.

@BarryCarlyon I’ve given the extension for review but could you guys tell me, if i could, test my extension from someone else’s channel with out it being released from the review testing?

Use the extension testing whitelist

  • Manage a extension
  • Version
  • Manage a version
  • Access
  • Add Twitch ID’s to Testing Accounts
1 Like

@BarryCarlyon Thank you Barry.
i love you. :wink: