# Automatically adding permissions to JWT on first login

**URL:** <https://community.auth0.com/t/automatically-adding-permissions-to-jwt-on-first-login/40559>\
**Category:** Get Help\
**Created:** [April 6, 2020, 2:34am UTC](https://community.auth0.com/t/automatically-adding-permissions-to-jwt-on-first-login/40559 "2020-04-06T02:34:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![OmegaVVeapon](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/omegavveapon/32/15226_2.png) [@OmegaVVeapon](https://community.auth0.com/u/OmegaVVeapon)\
**Post date:** [April 6, 2020, 2:34am UTC](https://community.auth0.com/t/automatically-adding-permissions-to-jwt-on-first-login/40559/1 "2020-04-06T02:34:21Z")

</div>

Hi,

I’m trying to ensure that users have a given role automatically added when they register.

Initially, I tried to do this with a “Post User Registration” hook but that never worked. (I don’t have an `auth0` object available to me with a management access token in a hook it seems…)

Then, I used the code provided in [this FAQ](http://community.auth0.com/t/how-do-i-add-a-default-role-to-a-new-user-on-first-login/25857) to do it when they first logged in at least, and that worked.

However, the first JWT that gets returned does NOT have the permissions associated to the added role. I noticed people were having the same issue as me in [this ticket…](http://community.auth0.com/t/after-applying-a-role-to-a-user-using-a-rule-at-signup-first-login-the-permissions-are-not-in-the-users-access-token/32884). However, I wasn’t super happy with the proposed solution of simply getting more tokens until one has the permissions…

So I’m sorta stuck atm. Does anyone have a way for a user’s JWT to contain the permissions associated with a role in the FIRST login?

---

<div class="post-metadata">

**Author:** ![OmegaVVeapon](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/omegavveapon/32/15226_2.png) [@OmegaVVeapon](https://community.auth0.com/u/OmegaVVeapon)\
**Post date:** [April 6, 2020, 6:44pm UTC](https://community.auth0.com/t/automatically-adding-permissions-to-jwt-on-first-login/40559/2 "2020-04-06T18:44:12Z")

</div>

Got it working by assigning the role to the user in the “Post User Registration” hook.

Was never able to make this work inside a rule, which is fine, I think the hook solution is more elegant.

Feel free to close.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 6, 2020, 8:26pm UTC](https://community.auth0.com/t/automatically-adding-permissions-to-jwt-on-first-login/40559/3 "2020-04-06T20:26:59Z")

</div>

Thanks for following up!

---

<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:** [April 21, 2020, 8:27pm UTC](https://community.auth0.com/t/automatically-adding-permissions-to-jwt-on-first-login/40559/4 "2020-04-21T20:27:02Z")

</div>

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