# How to read all role and permissoin for logged in user

**URL:** <https://community.auth0.com/t/how-to-read-all-role-and-permissoin-for-logged-in-user/58869>\
**Category:** Get Help\
**Tags:** auth0\
**Created:** [March 4, 2021, 7:45am UTC](https://community.auth0.com/t/how-to-read-all-role-and-permissoin-for-logged-in-user/58869 "2021-03-04T07:45:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mail4mithu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mail4mithu/32/12776_2.png) [@mail4mithu](https://community.auth0.com/u/mail4mithu)\
**Post date:** [March 4, 2021, 7:45am UTC](https://community.auth0.com/t/how-to-read-all-role-and-permissoin-for-logged-in-user/58869/1 "2021-03-04T07:45:40Z")

</div>

We are trying to use Auth0 for SPA application in javascript.  
Authenticating using Azure connection and getting idToken on success.  
The requirement is to read roles and permission for logged-in to restrict pages based on roles and permission.  
Please guide us on how to achieve this.

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [March 4, 2021, 12:07pm UTC](https://community.auth0.com/t/how-to-read-all-role-and-permissoin-for-logged-in-user/58869/3 "2021-03-04T12:07:38Z")

</div>

Hi @mail4mithu,

Thanks for joining the Community! 🙂

You can add the role/permissions to the ID Token or Access Token by using a custom claim in a [Rule](https://auth0.com/docs/rules).

Here is a related topic that shows you how to add permissions to the ID Token: [Accessing the permissions array in the access token - #10 by ryantomaselli](https://community.auth0.com/t/accessing-the-permissions-array-in-the-access-token/27559/10)

And here is how to add the user roles to tokens: [Sample Use Cases: Rules with Authorization](https://auth0.com/docs/authorization/sample-use-cases-rules-with-authorization#add-user-roles-to-tokens)

Let me know if you have any questions about these examples!

Stephanie

---

<div class="post-metadata">

**Author:** ![mail4mithu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mail4mithu/32/12776_2.png) [@mail4mithu](https://community.auth0.com/u/mail4mithu)\
**Post date:** [March 4, 2021, 2:09pm UTC](https://community.auth0.com/t/how-to-read-all-role-and-permissoin-for-logged-in-user/58869/4 "2021-03-04T14:09:22Z")

</div>

Thank you, Stephanie, for your help, I am able to get roles now. one small question can I change the name from link to roles? when I change it was not returning roles.  
 ![image](https://global.discourse-cdn.com/auth0/original/3X/f/6/f628c1bb1996a2bc84c96e3ae2de53c5111470a9.png)

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [March 5, 2021, 6:13pm UTC](https://community.auth0.com/t/how-to-read-all-role-and-permissoin-for-logged-in-user/58869/5 "2021-03-05T18:13:04Z")

</div>

Hi @mail4mithu,

Any custom claims must be namespaced to be OIDC-compliant so that your claims won’t collide with reserved claims. This is typically done with a URI such as `http://www.myexample.com/`.

So you can change the URI to something specific to your app, but it’s recommended that you use a URI as the namespace.

You can read more about namespacing custom claims here:

> **[Create Custom Claims](https://auth0.com/docs/secure/tokens/json-web-tokens/create-custom-claims)**
>
> Learn how to create collision-resistant names for custom claims.

---

<div class="post-metadata">

**Author:** ![mail4mithu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mail4mithu/32/12776_2.png) [@mail4mithu](https://community.auth0.com/u/mail4mithu)\
**Post date:** [March 5, 2021, 6:15pm UTC](https://community.auth0.com/t/how-to-read-all-role-and-permissoin-for-logged-in-user/58869/6 "2021-03-05T18:15:46Z")

</div>

Thank you @stephanie.chamblee for your help.

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [March 5, 2021, 6:16pm UTC](https://community.auth0.com/t/how-to-read-all-role-and-permissoin-for-logged-in-user/58869/7 "2021-03-05T18:16:46Z")

</div>

No problem! Happy to help!

---

<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:** [March 20, 2021, 6:17pm UTC](https://community.auth0.com/t/how-to-read-all-role-and-permissoin-for-logged-in-user/58869/8 "2021-03-20T18:17:26Z")

</div>

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