# Returning Realm Roles in Token

**URL:** <https://forum.keycloak.org/t/returning-realm-roles-in-token/15946>\
**Category:** Miscellanaeous\
**Created:** [June 11, 2022, 1:00pm UTC](https://forum.keycloak.org/t/returning-realm-roles-in-token/15946 "2022-06-11T13:00:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carl](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/carl/32/10443_2.png) [@Carl](https://forum.keycloak.org/u/Carl)\
**Post date:** [June 11, 2022, 1:00pm UTC](https://forum.keycloak.org/t/returning-realm-roles-in-token/15946/1 "2022-06-11T13:00:56Z")

</div>

Hi,

I added a User Realm Role Mapper to the off-the-shelf /account Client. When I print out the token, I see resource\_access which returns the correct (default) roles for the client. However, I don’t see a realm\_access section when I log in to /account.

I used Add Builtin to hook the Realm Role Mapper to the client.

I’m running 18 in dev mode and restarted a few times. Is there a setting I’m missing to put this Mapper into effect?

Thanks,  
Carl

---

<div class="post-metadata">

**Author:** ![Carl](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/carl/32/10443_2.png) [@Carl](https://forum.keycloak.org/u/Carl)\
**Post date:** [June 11, 2022, 1:08pm UTC](https://forum.keycloak.org/t/returning-realm-roles-in-token/15946/2 "2022-06-11T13:08:11Z")

</div>

I’ve tried a few Scope settings too like “Full Scope Allowed” and moving all the roles to the assigned list.

---

<div class="post-metadata">

**Author:** ![Carl](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/carl/32/10443_2.png) [@Carl](https://forum.keycloak.org/u/Carl)\
**Post date:** [June 12, 2022, 12:30pm UTC](https://forum.keycloak.org/t/returning-realm-roles-in-token/15946/3 "2022-06-12T12:30:43Z")

</div>

My test case is as follows. I tried this on KC 17 and 18

1. Create a realm
2. Create a user
3. On the Client “Account”, add a User Realm Roles Mapper
4. On the Client “Account”, set Full Scope Allowed
5. Log on to Client “Account”
6. Print the token
7. Verify that there is no realm\_access section

I also created a Realm Role “myrole” and add it to the user to see if maybe the defaults were deliberately not sent.

---

<div class="post-metadata">

**Author:** ![Carl](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/carl/32/10443_2.png) [@Carl](https://forum.keycloak.org/u/Carl)\
**Post date:** [June 12, 2022, 1:13pm UTC](https://forum.keycloak.org/t/returning-realm-roles-in-token/15946/4 "2022-06-12T13:13:20Z")

</div>

I also cleared the cache and verified that the realm\_access section shows up in the Client Scopes / Evaluate / Generated Access Token tab. The token shown in the console does not have the same fields as what I get from the POST /token call.

---

<div class="post-metadata">

**Author:** ![Carl](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/carl/32/10443_2.png) [@Carl](https://forum.keycloak.org/u/Carl)\
**Post date:** [June 12, 2022, 1:15pm UTC](https://forum.keycloak.org/t/returning-realm-roles-in-token/15946/5 "2022-06-12T13:15:32Z")

</div>

heh. Mixed up the clients. I was troubleshooting account when the token was based on account-console. Adding Full Scope Allowed to this client worked.
