Not getting user_id from jwt token

I’m hooking into the twitch.onAuthorized() call to decode the auth.token value, and from there pull out the user_id value. I need this value for identifying users in the extension. However, for some reason on one of our developer accounts, the decoded token contains the user_id of any viewers who can see the extension, but on my account, when I decode the token the user_id is missing. Both accounts are using the same extension.

This is what I see when I decode the auth.token value:

channel_id: “XXXXXXXXX”
exp: 1561072393
is_unlinked: false
opaque_user_id: “XXXXXXXXXXXXXXXXXXXX”
pubsub_perms: Object
role: “viewer”

Note that the user_id is missing. Anyone know why I’m not getting that field back, when on another developer’s account, his extension is getting back that field? Thanks!

You only get a user_id field if the user shares their identity with the extension.

How do I get the user to share their identity with the extension?

First the extension has to have selected the option to request identity link in the Extension Capabilities section.

Then you can either use the requestIdShare helper function as mentioned in the docs https://dev.twitch.tv/docs/extensions/reference/#helper-actions or the user can click the permissions button for the extension (which is the bottom right of the panel for panel extensions, or for video extensions it can be found through the extensions icon at the bottom of the stream player).

Only once the user has agreed to share their identity (which they can later revoke if they choose to no longer share their ID with your extension) will the JWT include the user_id.

1 Like

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