# Auth0 not returning user roles - Angular SPA

**URL:** <https://community.auth0.com/t/auth0-not-returning-user-roles-angular-spa/87806>\
**Category:** Get Help\
**Tags:** roles, auth0\
**Created:** [July 28, 2022, 9:10am UTC](https://community.auth0.com/t/auth0-not-returning-user-roles-angular-spa/87806 "2022-07-28T09:10:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![it-phoenix](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/it-phoenix/32/33468_2.png) [@it-phoenix](https://community.auth0.com/u/it-phoenix)\
**Post date:** [July 28, 2022, 9:10am UTC](https://community.auth0.com/t/auth0-not-returning-user-roles-angular-spa/87806/1 "2022-07-28T09:10:08Z")

</div>

Hi community,

I’m facing an issue and I would like to know how to get the role data from user. The authentication is working well, the problem is that when I get the data from the user, I don’t have any property with the roles.

What I already did:

1 - Activate both options.

 ![image](https://global.discourse-cdn.com/auth0/original/3X/c/0/c0ad50fb009b163f9d37cd7a7d9b92f07c818c70.png)

2 - Library used: @auth0/auth0-angular

3 - I expect to see both properties below. But the properties are not there like the printscreen.

The observable that returns the user data is user$

Expected result:

![image](https://global.discourse-cdn.com/auth0/original/3X/a/7/a762411c89f4c9ff4f93b3e8fcececcea7beb691.png)

Current result:

![image](https://global.discourse-cdn.com/auth0/original/3X/f/4/f45a17eb7391f37470f3ca23bc5995a9b7cb3a7b.png)

Is there anything else to do? Am I missing any configuration?

Cheers,  
Guilherme Marques.

---

<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:** [July 29, 2022, 12:02am UTC](https://community.auth0.com/t/auth0-not-returning-user-roles-angular-spa/87806/4 "2022-07-29T00:02:16Z")

</div>

Hello @it-phoenix welcome back!

> [@it-phoenix](#):
>
> Is there anything else to do? Am I missing any configuration?

It looks like the data you’ve shared is tied to an ID token whereas the RBAC/Permissions settings apply to Access tokens. You’ll want to take a look at the following FAQ which outlines how to add roles/permissions to an ID token:

[https://community.auth0.com/t/how-to-add-roles-and-permissions-to-the-id-token-using-actions/84506?preview\_theme\_id=30](https://community.auth0.com/t/how-to-add-roles-and-permissions-to-the-id-token-using-actions/84506?preview_theme_id=30)

Let us know if you have any questions!

---

<div class="post-metadata">

**Author:** ![it-phoenix](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/it-phoenix/32/33468_2.png) [@it-phoenix](https://community.auth0.com/u/it-phoenix)\
**Post date:** [July 29, 2022, 1:28pm UTC](https://community.auth0.com/t/auth0-not-returning-user-roles-angular-spa/87806/5 "2022-07-29T13:28:08Z")

</div>

Hi tyf,  
Thanks for the help.  
We could fix the issue create a new rule.

Auth Pipeline - Rules - We added the following rule.

```auto
function (user, context, callback) {
  const namespace = 'http://schemas.microsoft.com/ws/2008/06/identity/claims';
  const assignedRoles = (context.authorization || {}).roles;
	const ManagementClient = require('auth0@2.17.0').ManagementClient;
  const management = new ManagementClient({token: auth0.accessToken,domain: auth0.domain});
  
 // const params = { id: user.user_id, page: 0, per_page: 50, include_totals: true };
  
  let idTokenClaims = context.idToken || {};
  let accessTokenClaims = context.accessToken || {};
	
  

  idTokenClaims[`${namespace}/role`] = assignedRoles;
  accessTokenClaims[`${namespace}/role`] = assignedRoles;

  context.idToken = idTokenClaims;
  context.accessToken = accessTokenClaims;
  callback(null, user, context);
}

```

Cheers,  
Guilherme Marques.

---

<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:** [July 29, 2022, 2:33pm UTC](https://community.auth0.com/t/auth0-not-returning-user-roles-angular-spa/87806/6 "2022-07-29T14:33:00Z")

</div>

No problem, happy to help! Good to know you were able to get this sorted with the new rule, and thanks for following up with the community 😄

---

<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 13, 2022, 2:33pm UTC](https://community.auth0.com/t/auth0-not-returning-user-roles-angular-spa/87806/7 "2022-08-13T14:33:37Z")

</div>

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