# Roles not included in custom claim through actions

**URL:** <https://community.auth0.com/t/roles-not-included-in-custom-claim-through-actions/84407>\
**Category:** Get Help\
**Tags:** login\
**Created:** [June 1, 2022, 3:22pm UTC](https://community.auth0.com/t/roles-not-included-in-custom-claim-through-actions/84407 "2022-06-01T15:22:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joel.paredes](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/joel.paredes/32/33352_2.png) [@joel.paredes](https://community.auth0.com/u/joel.paredes)\
**Post date:** [June 1, 2022, 3:22pm UTC](https://community.auth0.com/t/roles-not-included-in-custom-claim-through-actions/84407/1 "2022-06-01T15:22:40Z")

</div>

Hi!

I need to retrieve the user assigned roles on login. I have added an action that adds a custom claim as follows:

```auto
exports.onExecutePostLogin = async (event, api) => {
  const namespace = 'https://example.com';

  if (event.authorization) {
    api.idToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
    api.accessToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
  }
}

```

However, the access token gives

```auto
"https://example.com/roles": [],

```

I am using organizations. I have also activated RBAC in my default audience api and the permissions claim is empty as well.

```auto
"permissions": []

```

Any idea of what is causing this?

---

<div class="post-metadata">

**Author:** ![joel.paredes](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/joel.paredes/32/33352_2.png) [@joel.paredes](https://community.auth0.com/u/joel.paredes)\
**Post date:** [June 1, 2022, 3:48pm UTC](https://community.auth0.com/t/roles-not-included-in-custom-claim-through-actions/84407/2 "2022-06-01T15:48:08Z")

</div>

Never mind, I found the issue.

For anyone facing the same as me. I needed to add organization specific roles. Here are the docs:

> **[Add Roles to Organization Members](https://auth0.com/docs/manage-users/organizations/configure-organizations/add-member-roles)**
>
> Learn how to add roles to Organization members using the Auth0 Dashboard or Management API.

---

<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:** [June 1, 2022, 6:22pm UTC](https://community.auth0.com/t/roles-not-included-in-custom-claim-through-actions/84407/3 "2022-06-01T18:22:35Z")

</div>

Hey @joel.paredes thanks for following up with the solution, glad you were able to get this sorted!

---

<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:** [June 16, 2022, 6:22pm UTC](https://community.auth0.com/t/roles-not-included-in-custom-claim-through-actions/84407/4 "2022-06-16T18:22:53Z")

</div>

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