# Payload has no roles in accessToken

**URL:** <https://community.auth0.com/t/payload-has-no-roles-in-accesstoken/104546>\
**Category:** Get Help\
**Tags:** classic-universal-login-experience, login-experience\
**Created:** [April 12, 2023, 3:00pm UTC](https://community.auth0.com/t/payload-has-no-roles-in-accesstoken/104546 "2023-04-12T15:00:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedro.sarmento](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@pedro.sarmento](https://community.auth0.com/u/pedro.sarmento)\
**Post date:** [April 12, 2023, 3:00pm UTC](https://community.auth0.com/t/payload-has-no-roles-in-accesstoken/104546/1 "2023-04-12T15:00:00Z")

</div>

Hello,  
I am having problems getting the roles of a user.

I have created the roles and associated users with them. Two Roles Admin and User and two users one for each role.

I also have created in the Login flow the code to get the roles:

```auto
exports.onExecutePostLogin = async (event, api) => {
  const namespace = 'https://dev-1flzkotdey2fm74y.us.auth0.com';
  if (event.authorization) {
    api.idToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
    api.accessToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
  }
};

```

I request the getAccessTokenSilently and the accessToken is received with the payload but the roles are not coming:

```auto
{
  "iss": "https://dev-1flzkotdey2fm74y.us.auth0.com/",
  "sub": "auth0|642335d4e1118da83ff192a5",
  "aud": [
    "https://dev-1flzkotdey2fm74y.us.auth0.com/api/v2/",
    "https://dev-1flzkotdey2fm74y.us.auth0.com/userinfo"
  ],
  "iat": 1681297803,
  "exp": 1681384203,
  "azp": "OairsgbVMfSz5GNl6k0QuWXq4kmcmqPQ",
  "scope": "openid profile email"
}

```

What am I missing?

Best regards,

---

<div class="post-metadata">

**Author:** ![pedro.sarmento](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@pedro.sarmento](https://community.auth0.com/u/pedro.sarmento)\
**Post date:** [April 12, 2023, 3:20pm UTC](https://community.auth0.com/t/payload-has-no-roles-in-accesstoken/104546/2 "2023-04-12T15:20:01Z")

</div>

My CreateAuth0 is like:

```auto
export default createAuth0({
    domain: process.env.VUE_APP_AUTH0_DOMAIN,
    clientId: process.env.VUE_APP_AUTH0_CLIENT_ID,
    scope: process.env.VUE_APP_AUTH0_SCOPE,
    authorizationParams: {
        audience: process.env.VUE_APP_AUTH0_AUDIENCE,
        redirect_uri: process.env.VUE_APP_BASE_URL + '/' + process.env.VUE_APP_AUTH0_REDIRECT + '/'
    },
    onRedirectCallback: appState => {
        router.push(
            appState && appState.targetUrl
                ? appState.targetUrl
                : window.location.pathname
        );
    }
})

```

---

<div class="post-metadata">

**Author:** ![pedro.sarmento](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@pedro.sarmento](https://community.auth0.com/u/pedro.sarmento)\
**Post date:** [April 12, 2023, 3:22pm UTC](https://community.auth0.com/t/payload-has-no-roles-in-accesstoken/104546/3 "2023-04-12T15:22:34Z")

</div>

And here are the images of the Auth0 console:

 ![User](https://global.discourse-cdn.com/auth0/original/3X/5/4/54a2e01f0b84f704ec36d6b0808546930c5101f1.jpeg)  
 ![Roles](https://global.discourse-cdn.com/auth0/original/3X/4/f/4f768c69191d93b6bbbfeaffc03f00daba88e44e.jpeg)

---

<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:** [April 12, 2023, 6:26pm UTC](https://community.auth0.com/t/payload-has-no-roles-in-accesstoken/104546/5 "2023-04-12T18:26:10Z")

</div>

Hey there @pedro.sarmento!

Thanks for the detailed description and screenshots - The issue here is that you cannot use `auth0.com` in your namespace. Please see the guidelines here:

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

Other than that, everything looks good - If you change your namespace you should be good to go 🚀

---

<div class="post-metadata">

**Author:** ![pedro.sarmento](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@pedro.sarmento](https://community.auth0.com/u/pedro.sarmento)\
**Post date:** [April 12, 2023, 6:42pm UTC](https://community.auth0.com/t/payload-has-no-roles-in-accesstoken/104546/6 "2023-04-12T18:42:13Z")

</div>

Thank you!

Problem solved

---

<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:** [April 12, 2023, 10:29pm UTC](https://community.auth0.com/t/payload-has-no-roles-in-accesstoken/104546/7 "2023-04-12T22:29:36Z")

</div>

No problem, happy to help! Thanks for confirming 🙂

---

<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 26, 2023, 10:29pm UTC](https://community.auth0.com/t/payload-has-no-roles-in-accesstoken/104546/8 "2023-04-26T22:29:40Z")

</div>

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