# Keycloak - Missing data in the userinfo response

**URL:** <https://forum.keycloak.org/t/keycloak-missing-data-in-the-userinfo-response/19550>\
**Category:** Getting advice\
**Tags:** authentication, oidc\
**Created:** [January 11, 2023, 7:46pm UTC](https://forum.keycloak.org/t/keycloak-missing-data-in-the-userinfo-response/19550 "2023-01-11T19:46:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MohammedAdain](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/mohammedadain/32/6377_2.png) [@MohammedAdain](https://forum.keycloak.org/u/MohammedAdain)\
**Post date:** [January 11, 2023, 7:46pm UTC](https://forum.keycloak.org/t/keycloak-missing-data-in-the-userinfo-response/19550/1 "2023-01-11T19:46:07Z")

</div>

Even after configuring Client scopes which have `client roles` and `realm roles` mappers mapped to them, ref image:  
[![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/9/90d5dce65132f55e2febf49e1044f0eba417c11e.png)](https://user-images.githubusercontent.com/61708483/211900606-765338e1-ef7e-4668-9e23-1480226715e5.png)  
and even after toggling `Add to Userinfo` to ON  
[![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/4/491aa86d99ebfeb2b4e0783dbeddd6a821bfda2f.png)](https://user-images.githubusercontent.com/61708483/211900877-9e8df903-78cb-4771-b8a1-aa465f8bd5d9.png)  
the user info doesn’t return realm roles as part of the response.  
I did add a `realm roles` mapper to dedicated client scope as well and toggled `Add to Userinfo` to ON here too  
[![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/6/626d23ce3bb541c3cc4ef6d8cbc128d0ce312f3f.png)](https://user-images.githubusercontent.com/61708483/211901560-5a80cf9e-dc5e-443c-8f4a-a25f4d58d8c2.png)  
but the userinfo still doesn;t return a full response containing roles. One such response after hitting user info endpoint:

```auto
{"sub":"ccd1ab6c-0c54-4f27-82a9-092376a66cf4","preferred_username":"access_user","given_name":"","family_name":"","email":"access_user@access.com"}

```

### Version

19.0.1

### Expected behavior

The user info should contain `roles ` claims too.

### Actual behavior

One such response after hitting user info endpoint:

```auto
{"sub":"ccd1ab6c-0c54-4f27-82a9-092376a66cf4","preferred_username":"access_user","given_name":"","family_name":"","email":"access_user@access.com"}

```

### How to Reproduce?

Described in `Describe the Bug` section

### Anything else?

Refs:

1. [openid - Keycloak - Missing data in the userinfo response - Stack Overflow](https://stackoverflow.com/questions/58584131/keycloak-missing-data-in-the-userinfo-response)
2. [openid connect - Get the user roles with the keycloak userinfo endpoint - Stack Overflow](https://stackoverflow.com/questions/57997377/get-the-user-roles-with-the-keycloak-userinfo-endpoint)

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [January 12, 2023, 8:56am UTC](https://forum.keycloak.org/t/keycloak-missing-data-in-the-userinfo-response/19550/2 "2023-01-12T08:56:15Z")

</div>

After creating your client, go into “Client scopes” → “{client}-dedicated” and click on “Add predefined mapper”

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/e/ef6aa7decae21fdf3a779674534f21d19fc8b9a7.png)

Select “realm roles” from the list:

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/6/6a9ee4f4f6db7b3514698416b0b796abc60a9e71.png)

After it’s created, click on it and make sure “Add to userinfo” is selected:

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/e/edfce7cc1d3f32c87d0d92b3fa0c78cb5e1b6a38.png)

It should be in your userinfo now:  
 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/6/657744f215f2d8c4c5b040a85e6093099789fe35.png)

---

<div class="post-metadata">

**Author:** ![davidbister](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/davidbister/32/8801_2.png) [@davidbister](https://forum.keycloak.org/u/davidbister)\
**Post date:** [June 17, 2023, 6:05pm UTC](https://forum.keycloak.org/t/keycloak-missing-data-in-the-userinfo-response/19550/3 "2023-06-17T18:05:09Z")

</div>

Hi xgp, but why then only default realm roles ? and not roles that are created afterwards and added to the user ?
