Cannot get user id in local/hosted test

Hello,

I’ve been going through all the forums but i cannot find anything to help me: I’ve been doing some local and hosted test of my extension and I cannot get the user id in the JWT. When it’s the broadcaster who installs the test extension, I get the user id but when I use any other account (that I added in the test account list), I can only get the opaque ID. I also never get the popup to allow sharing of the user id, I only get the popup saying it’s an unapproved extension. Can you please help?

Thanks
Julien

Did you enable the “Request Identity Link” capability?

Hi BarryCarlyon,

I forgot indeed to do it. I just did and it added an option to the bottom of my panel to share my account information:
image

Unfortunately when i try to check to content of onAuthorize; i still get the same opaque id. Maybe it’s different in the JWT? I could not check right away but I was under the assumption that onAuthorize should give the same results.

Twitch.ext.onAuthorized((a)=>console.log(a));
instrument.js:108 {channelId: “618314972”, clientId: “w1tpnlsjmspoukzdnjz2wdczy3wczs”, token: “eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2M…iXX19.aWyg9yYYNpisUYXwRyyGT319ITG50Qvw54xsg5_4yjw”, userId: “UqxqSCjozUX31-NF72L3g”}

Is there something I’m missing?

On a slightly different matter, I’d like to proactively pop the permission popup, without the user to have to go and click himself on the icon; is that possible?

Thank you very much for your valuable help.

Julien

Thats expected, the opaqueID is essentially a session ID, so in the example of a game, you let a logged out player play level 1, then prompt to login (share their ID) to save their progress, as the opquaeID shouldn’t change during the login process.

The userID is encoded in the token itself

See

For an example, to extract the userID from a decoded JWT Token

Or for frontend usage

window.Twitch.ext.viewer.id

It’s considered bad practice to auto prompt, but you can do it

my example generates a “obvious” button for people to click

The function is window.Twitch.ext.actions.requestIdShare();

Thank You very much Barry, it will help me a lot. I don’t want to pop it right away indeed, I agree it’s not very user friendly but my current implementation uses twitch id in the backend and I haven’t figured out how to migrate to using opaque ID and then matching with the real id on my website when the user comes for other purposes.