# Getting Twitch UserID from onAuthorized auth.userid instead of auth.token

**URL:** <https://discuss.dev.twitch.com/t/getting-twitch-userid-from-onauthorized-auth-userid-instead-of-auth-token/15429>\
**Category:** Extensions\
**Created:** [April 22, 2018, 9:04am UTC](https://discuss.dev.twitch.com/t/getting-twitch-userid-from-onauthorized-auth-userid-instead-of-auth-token/15429 "2018-04-22T09:04:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Seravy](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/seravy/32/3599_2.png) [@Seravy](https://discuss.dev.twitch.com/u/Seravy)\
**Post date:** [April 22, 2018, 9:04am UTC](https://discuss.dev.twitch.com/t/getting-twitch-userid-from-onauthorized-auth-userid-instead-of-auth-token/15429/1 "2018-04-22T09:04:16Z")

</div>

If someone could give some advice, I have ‘Request Identity Link’ checked on my extension and the document says ‘Once the viewer accepts your request to share his Twitch identity, his numeric Twitch ID is provided in the Extension Helper’s onAuthorized() callback function.’  
Up until now i have been using the JWT token to get the Twitch ID (numeric) from, but recently i tried to get that ID from auth.userId. Tried refreshing, being on another channel, doesn’t make a difference to the auth.userid.

window.Twitch.ext.onAuthorized((auth: any) =\> {  
Without granting permissions: auth.userId = “Uxxxxxxxxxxxxxx\_xxxxx”  
After granting permissions: auth.userId: “U\_xxxxxxx\_xxxxxxxxxxx”

I can get the twitchid from the token using this function:

function parseJwt (token: string): { channel\_id: string, opaque\_user\_id: string, pubsub\_perms: { listen: string[], send: string[] }, role: string, user\_id?: string } {  
var base64Url = token.split(’.’)[1];  
var base64 = base64Url.replace(’-’, ‘+’).replace(’\_’, ‘/’);  
return JSON.parse(window.atob(base64));  
};

but is there anyway to get it from auth.userid?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [April 22, 2018, 7:20pm UTC](https://discuss.dev.twitch.com/t/getting-twitch-userid-from-onauthorized-auth-userid-instead-of-auth-token/15429/2 "2018-04-22T19:20:22Z")

</div>

> [@Seravy](#):
>
> Up until now i have been using the JWT token to get the Twitch ID (numeric) from

Thats the only way to do it. Parsing the JWT

U-references have no correlation with a TwitchID

---

<div class="post-metadata">

**Author:** ![Seravy](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/seravy/32/3599_2.png) [@Seravy](https://discuss.dev.twitch.com/u/Seravy)\
**Post date:** [April 23, 2018, 1:21am UTC](https://discuss.dev.twitch.com/t/getting-twitch-userid-from-onauthorized-auth-userid-instead-of-auth-token/15429/3 "2018-04-23T01:21:36Z")

</div>

Ah my mistake. I misunderstood the documentation. Thanks.
