# How to make roles a key in JSON rather than namespace - accessing custom claims from NodeJS/Express using Actions

**URL:** <https://community.auth0.com/t/how-to-make-roles-a-key-in-json-rather-than-namespace-accessing-custom-claims-from-nodejs-express-using-actions/80317>\
**Category:** Get Help\
**Created:** [March 22, 2022, 10:59am UTC](https://community.auth0.com/t/how-to-make-roles-a-key-in-json-rather-than-namespace-accessing-custom-claims-from-nodejs-express-using-actions/80317 "2022-03-22T10:59:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nc14](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nc14/32/33226_2.png) [@nc14](https://community.auth0.com/u/nc14)\
**Post date:** [March 22, 2022, 10:59am UTC](https://community.auth0.com/t/how-to-make-roles-a-key-in-json-rather-than-namespace-accessing-custom-claims-from-nodejs-express-using-actions/80317/1 "2022-03-22T10:59:19Z")

</div>

I’ve used an action to add roles my ID token using this script :

```auto

exports.onExecutePostLogin = async (event, api) => {
  const namespace = 'https://my-app.example.com';
  if (event.authorization) {
    api.idToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
    api.accessToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
  }
}

```

But the output of the JSON in the token is now like this :

```auto
{
  'https://localhost:3000.com/roles': ['user'],
  nickname: 'test',
  name: 'test@test.com',
  picture: 'https://s.gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fte.png',
  updated_at: '2022-03-22T14:26:31.519Z',
  email: 'test@test.com',
  email_verified: false,
  sub: 'auth0|6228c2435b5a0b00700561f1'
}

```

I EITHER want it to be like

roles: [‘user’]  
nickname: ‘test’,  
etc

So it is easier to access using req.oidc.user.roles

**OR alternatively, how do I access the roles value from here in NodeJS/Express?**

```auto

```

---

<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:** [March 30, 2022, 4:58pm UTC](https://community.auth0.com/t/how-to-make-roles-a-key-in-json-rather-than-namespace-accessing-custom-claims-from-nodejs-express-using-actions/80317/3 "2022-03-30T16:58:53Z")

</div>

Hey there @nc14 !

> [@nc14](#):
>
> `'https://localhost:3000.com/roles': ['user'],`

This is [expected behavior](https://auth0.com/docs/secure/tokens/json-web-tokens/create-namespaced-custom-claims) and there unfortunately isn’t anyway around the requirement for namespaced custom claims currently. I have heard rumblings that this may be enabled in the future (a common ask), however I’m unable to provide any sort of timeline on that front.

---

<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 22, 2022, 9:53pm UTC](https://community.auth0.com/t/how-to-make-roles-a-key-in-json-rather-than-namespace-accessing-custom-claims-from-nodejs-express-using-actions/80317/4 "2022-04-22T21:53:58Z")

</div>


