# How to add user group info as part of access token?

**URL:** <https://community.auth0.com/t/how-to-add-user-group-info-as-part-of-access-token/88107>\
**Category:** Get Help\
**Tags:** auth0\
**Created:** [August 3, 2022, 12:04pm UTC](https://community.auth0.com/t/how-to-add-user-group-info-as-part-of-access-token/88107 "2022-08-03T12:04:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![selvi\_ranganathan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/selvi_ranganathan/32/34155_2.png) [@selvi\_ranganathan](https://community.auth0.com/u/selvi_ranganathan)\
**Post date:** [August 3, 2022, 12:04pm UTC](https://community.auth0.com/t/how-to-add-user-group-info-as-part-of-access-token/88107/1 "2022-08-03T12:04:33Z")

</div>

Tried below code for fetching group information , but I didn’t get group info as part of access token

// rule script  
context.idToken[namespace + ‘/groups’] = user.groups;

---

<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 3, 2022, 10:33pm UTC](https://community.auth0.com/t/how-to-add-user-group-info-as-part-of-access-token/88107/3 "2022-08-03T22:33:51Z")

</div>

Hello @selvi_ranganathan welcome to the community!

Are you by chance mistaking `groups` for `roles`? [Here](https://auth0.com/docs/manage-users/access-control/sample-use-cases-rules-with-authorization#add-user-roles-to-tokens) is an example of adding roles to tokens in the context of a Rule, and [here](https://community.auth0.com/t/how-to-add-roles-and-permissions-to-the-id-token-using-actions/84506?preview_theme_id=30) within the context of an Action.

We recommend using Actions if you can, hope this helps 😄

---

<div class="post-metadata">

**Author:** ![selvi\_ranganathan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/selvi_ranganathan/32/34155_2.png) [@selvi\_ranganathan](https://community.auth0.com/u/selvi_ranganathan)\
**Post date:** [August 4, 2022, 11:36am UTC](https://community.auth0.com/t/how-to-add-user-group-info-as-part-of-access-token/88107/4 "2022-08-04T11:36:19Z")

</div>

@tyf No I just want to know how can I get which user belongs to which groups, not roles

---

<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 5, 2022, 9:19pm UTC](https://community.auth0.com/t/how-to-add-user-group-info-as-part-of-access-token/88107/6 "2022-08-05T21:19:32Z")

</div>

Ahh OK gotcha! Thanks for clarifying 🙂 I assume you are using the [Authorization Extension](https://community.auth0.com/t/how-to-add-user-group-info-as-part-of-access-token/88107/5)?

> [@selvi\_ranganathan](#):
>
> Tried below code for fetching group information , but I didn’t get group info as part of access token

Justo clarify, the groups claim will be in the ID Token as opposed to the Access Token using the code above.

Typically, if the groups claim is not showing up in an a token it is due to a misconfiguration - There are a few steps you may want to double check if you are not receiving `groups` in your ID Token:

- Configured the Authorization extension to to include groups as part of the `user` context.

- Published the extension required rule, AND are sure that is placed ahead of your rule to add the groups to the ID Token.

Configuration steps are outlined here and [here](https://auth0.com/docs/customize/extensions/authorization-extension/use-rules-with-the-authorization-extension#add-custom-claims-to-the-issued-token) is an example of a role adding groups to the ID Token.

Hope this helps!

---

<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 20, 2022, 9:19pm UTC](https://community.auth0.com/t/how-to-add-user-group-info-as-part-of-access-token/88107/7 "2022-08-20T21:19:57Z")

</div>

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