Email not returning from user profile

I saw on a thread here that you should be able to return email from https://id.twitch.tv/oauth2/userinfo: OAuth2Strategy doesnt provide email in user profile - #5 by BarryCarlyon

I’m using this as Helix isn’t working for us + I’ve been going through the OIDC docs and it looks like what we need: Using OIDC to get OAuth Access Tokens | Twitch Developers

Authorization URL looks like: https://id.twitch.tv/oauth2/authorize?client_id=&response_type=code&claims={userinfo:{email:null,email_verified:null,picture:null,preferred_username:null}

Token URL: https://id.twitch.tv/oauth2/token

Scopes: ‘user:read:email’, ‘openid’

It looks like the rest of the profile is returned, other than email (+ is there a unique twitch ID I can return as well?). Otherwise, this is pretty much what gets returned:

{"aud": "xxx", "azp": "xxx", "exp": xxx, "iat": xxx, "iss": "https://id.twitch.tv/oauth2", "sub": "xxx", "preferred_username": "xxx"}

Thanks!

You did call userinfo as documented here Using OIDC to get OAuth Access Tokens | Twitch Developers ?

You didn’t get picture back either which suggest something is awry.

Here yoru claims lack " so this suggests your Claism are not JSON encoded correctly, and URI encoded

it should be more like

https://id.twitch.tv/oauth2/authorize?client_id=MYCLIENTID&redirect_uri=URIENCODEDREDIRECT&response_type=code&force_verify=true&scope=openid&state=cX98K%2FvC1yBBCnMZBh0Fag%3D%3D&claims=%7B%22userinfo%22:%7B%22email%22:null,%22email_verified%22:null,%22picture%22:null,%22preferred_username%22:null%7D%7D

Which’ll display something like (it might display like this even with invalid claims)

Thanks!, I fixed it - had it in

"id_token": {
    "email": null,
    "email_verified": null
  },
  "userinfo": {
    "picture": null
  }

instead of

"userinfo": {
    "picture": null,
    "email": null
  }

Regarding the other fields there (e.g. aud, azp, exp), are any one of them a unique ID I can refer to the user as?

That would be the sub key

That sub key is the users unique Twitch User ID

Amazing, thank you!