Does auth.userId fixed for the user


#1

Hi,
I’m working on extension that will work as video overlay.
I’m trying to use user auth (userId) to save some data to the user, these data will be shown again when the user come back.
I’m trying to use auth.userId as a key to store these info, but in developer-rig, every page load (refresh page) the user has different user id.

window.Twitch.ext.onAuthorized(auth =>  console.log(auth.userId) );

While this written in the docs, that the auth.userId is not changed (just in some cases), but this is not what happens while I’m developing using developer-rig environment.

Opaque IDs persist across all channels, and they do not change unless viewers explicitly request to rotate their identity.

Can you explain this misunderstanding.


#2

I haven’t played with the latest version of the rig so I’m not up to date on how it generates opaque ID’s for testing, but there are some things to keep in mind:

There are 2 types of Opaque IDs, ones prefixed by a U and ones prefixed by an A.

If the ID starts with a U it means that the user is logged in to Twitch, and so that ID will persist only for the length of their session (so it’ll persist through refreshes, but wont lat indefinitely). Ideally you should not rely on this as a key for long-term storage of user data.

If it’s prefixed by an A it means the user is not logged in to Twitch, and so this ID will change every time they load the page. Not only that, but it is possible for different users to have the same ID over time, so it is highly recommended not to be used as a key for storing any data beyond the very short term.

If you want to properly store data for a user, then the recommended way is to have them grant access to your app to view their User ID, which can then be decoded from the JWT token, as the Twitch User ID will never change.


#3

Thanks Dist,
Regarding to these references



I should use window.Twitch.ext.actions.requestIdShare((e) => {console.log(e)});, and this should show a prompt for users to accept sharing there id, but this is not occurred in developer-rig (no prompt has been shown), so the function (arrow function) not called at all.


#4

This function doesn’t work in the Rig and it’s on their “todo” list

As per