# Include user roles in JWT with auth0-angular?

**URL:** <https://community.auth0.com/t/include-user-roles-in-jwt-with-auth0-angular/85181>\
**Category:** Get Help\
**Tags:** sdk, auth0-angular, jwt, angular, auth0\
**Created:** [June 15, 2022, 3:29pm UTC](https://community.auth0.com/t/include-user-roles-in-jwt-with-auth0-angular/85181 "2022-06-15T15:29:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PhoenixG](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/phoenixg/32/33431_2.png) [@PhoenixG](https://community.auth0.com/u/PhoenixG)\
**Post date:** [June 15, 2022, 3:29pm UTC](https://community.auth0.com/t/include-user-roles-in-jwt-with-auth0-angular/85181/1 "2022-06-15T15:29:39Z")

</div>

Updating an Angular SPA in an existing system to use Auth0 instead. It _mostly_ works! Users can log in, and there is a custom user role guard for routing, so the application at least has all the required information (eg, user’s name and roles). Just one problem though…

The existing backend expects the user’s role(s) to be included **in the JWT** on API calls, and I can’t for the life of me figure out where to enable that.

The httpInterceptor works, and I get a JWT, but the existing backend is expecting “name” and “role” in the payload, neither of which are there.

For a moment, I thought the detailedResponse: true token option might be what I needed to include everything (even if that were overkill), but then instead of a bearer token it sends `[object Object]` (this may be an unrelated bug, so outside the scope of this question).

![Screenshot from 2022-06-15 08-07-56](https://global.discourse-cdn.com/auth0/original/3X/9/4/944996fac640eabd9292e558e86a22af8f3fe381.png)

So, where/how do I configure Auth0 to include _at least_ the user’s roles in the JWT? Is it in the auth0-angular library in the Angular application or maybe in the audience settings?

I feel the answer must be so basic that I’m missing something obvious, haha. The `global.d.ts` in the interface for GetTokenSilentlyOptions says:

> If you need to send custom parameters to the Authorization Server, make sure to use the original parameter name.

What does this mean? Can I setup the httpInterceptor tokenOptions to include the name/roles from auth.user$ in the JWT payload? If so, how?

---

<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 21, 2022, 11:47pm UTC](https://community.auth0.com/t/include-user-roles-in-jwt-with-auth0-angular/85181/3 "2022-06-21T23:47:32Z")

</div>

Hey there @PhoenixG welcome to the community, good to know it mostly works! Have you had any luck with adding roles to a user’s JWT?

> [@PhoenixG](#):
>
> So, where/how do I configure Auth0 to include _at least_ the user’s roles in the JWT? Is it in the auth0-angular library in the Angular application or maybe in the audience settings?

You can add a user’s roles to their tokens using Actions as outline in the following documentation:

> **[Sample Use Cases: Actions with Authorization](https://auth0.com/docs/manage-users/access-control/sample-use-cases-actions-with-authorization#add-user-roles-to-tokens)**
>
> Learn how to use Actions with roles-based access control (RBAC).

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:** [July 6, 2022, 11:47pm UTC](https://community.auth0.com/t/include-user-roles-in-jwt-with-auth0-angular/85181/4 "2022-07-06T23:47:44Z")

</div>

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