Email field is missing inside ID token

I’m integrating Twitch OIDC authorization code flow but the resulting id token is missing the email field.

Here’s is the scope:

channel:read:stream_key user:read:email openid

This is the claims I’m requesting:

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

Here’s the resulting auth code URL:

https://id.twitch.tv/oauth2/authorize?claims=%7B%22id_token%22%3A%7B%22email%22%3Anull%2C%22email_verified%22%3Anull%2C%22picture%22%3Anull%2C%22preferred_username%22%3Anull%7D%2C%22userinfo%22%3A%7B%22email%22%3Anull%2C%22email_verified%22%3Anull%7D%7D&client_id=XXXXXXXXXXXXXX&force_verify=true&nonce=XXXXXXXXXXXXXX&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fauth%2Fprovider%2Ftwitch%2Fcallback&response_type=code&scope=channel%3Aread%3Astream_key+user%3Aread%3Aemail+openid&state=XXXXXXXXXXXXXXXXXXX

And here is the content of ID token I get:

{
  "aud": "XXXXXXXXXXXXXXXXXXX",
  "exp": 1685081168,
  "iat": 1685080268,
  "iss": "https://id.twitch.tv/oauth2",
  "sub": "XXXXXXXXX",
  "email_verified": false,
  "nonce": "XXXXXXXXXXXXXXXXX",
  "picture": "https://static-cdn.jtvnw.net/user-default-pictures-uv/XXXXXXXXXXXXXXXXXXXXXXX-profile_image-150x150.png",
  "preferred_username": "XXXXXXXXXX"
}

The resulting token has everything (incl. email_verified) but doesn’t have email field. Am I missing something?

I’ve also tried to hit /userinfo endpoint but the email field is missing there too.

{ 
   "aud": "XXXXXXXXXXXXXX" 
   "email_verified": false 
   "exp": 1.685083754e+09 
   "iat":1.685082854e+09 
   "iss": "https://id.twitch.tv/oauth2" 
   "sub": "XXXXXXXXXXXX"
}

If the user hasn’t verified their email, it’s not going to be returned.

Thanks! Yea, already figured it out. Took me a while.
Might be worth to add a note about that to API documentation. Couldn’t find anything about it in there.

filed as OIDC email has to be verified to be returned by myinfo note · Issue #791 · twitchdev/issues · GitHub

1 Like

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