# What Restrictions Apply To The \`roles\` Claim?

**URL:** <https://community.auth0.com/t/what-restrictions-apply-to-the-roles-claim/113684>\
**Category:** Get Help\
**Tags:** user-profile, user-management\
**Created:** [August 15, 2023, 5:12pm UTC](https://community.auth0.com/t/what-restrictions-apply-to-the-roles-claim/113684 "2023-08-15T17:12:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![klausgy](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/klausgy/32/49929_2.png) [@klausgy](https://community.auth0.com/u/klausgy)\
**Post date:** [August 15, 2023, 5:12pm UTC](https://community.auth0.com/t/what-restrictions-apply-to-the-roles-claim/113684/1 "2023-08-15T17:12:53Z")

</div>

Hello, I know there are alreay many threads about roles in tokens, and I managed to get it working with Next Auth, as I outlined in my answer here: [next.js - Requesting User Roles With Auth0 And Next Auth - Stack Overflow](https://stackoverflow.com/questions/76906889/requesting-user-roles-with-auth0-and-next-auth)

However, I’m still stlightly confused, the custom claim documentation says that `roles` is a restricted claim, but I wonder, is there any way to use it for displaying roles? I didn’t get it to work with the claim `roles`, only `https://example.com/roles`, although, after rereading the documentation, maybe the problem was not the namespace but the restriction of the claim `roles`. But anyway, what are the restrictions for the claim `roles` and is it possible to work within them?

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [August 15, 2023, 9:37pm UTC](https://community.auth0.com/t/what-restrictions-apply-to-the-roles-claim/113684/3 "2023-08-15T21:37:49Z")

</div>

Hey @klausgy welcome to the community!

> [@klausgy](#):
>
> However, I’m still stlightly confused, the custom claim documentation says that `roles` is a restricted claim, but I wonder, is there any way to use it for displaying roles?

`roles` is indeed a restricted claim, and cannot be used directly as a claim to add roles in token(s) as you’ve seen.

> [@klausgy](#):
>
> But anyway, what are the restrictions for the claim `roles` and is it possible to work within them?

The restriction is on the use of the string `roles` as a custom claim itself - You can either use a custom namespace as you’ve demonstrated OR something like `userRoles` would also work. This is just in an effort to avoid any potential collisions while adhering to OIDC/OAuth protocols.

Hope this helps to clarify!

---

<div class="post-metadata">

**Author:** ![klausgy](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/klausgy/32/49929_2.png) [@klausgy](https://community.auth0.com/u/klausgy)\
**Post date:** [August 16, 2023, 7:46am UTC](https://community.auth0.com/t/what-restrictions-apply-to-the-roles-claim/113684/4 "2023-08-16T07:46:50Z")

</div>

Thanks a lot for the answer! Yes, it makes sense, but I wonder, does that meaan that the `roles` claim will always be undefined? Or is it possible to activate it somehow, not as a custom claim, but as the claim it is reserved for?

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [August 17, 2023, 12:00am UTC](https://community.auth0.com/t/what-restrictions-apply-to-the-roles-claim/113684/5 "2023-08-17T00:00:03Z")

</div>

No problem, happy to help!

> [@klausgy](#):
>
> Yes, it makes sense, but I wonder, does that mean that the `roles` claim will always be undefined?

Even if you attempt to add `roles` as a custom claim it will just be ignored altogether, so it is more or less just off limits. I will note that it is common practice to infer roles from permissions so the extra step to add the actual roles as custom claims by way of a rule/action is not necessarily required.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [August 31, 2023, 12:00am UTC](https://community.auth0.com/t/what-restrictions-apply-to-the-roles-claim/113684/6 "2023-08-31T00:00:05Z")

</div>

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