# What doesn't namespace refer to in this example?

**URL:** <https://community.auth0.com/t/what-doesnt-namespace-refer-to-in-this-example/70575>\
**Category:** Get Help\
**Tags:** auth0\
**Created:** [September 30, 2021, 7:50pm UTC](https://community.auth0.com/t/what-doesnt-namespace-refer-to-in-this-example/70575 "2021-09-30T19:50:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![brett2](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brett2/32/22642_2.png) [@brett2](https://community.auth0.com/u/brett2)\
**Post date:** [September 30, 2021, 7:50pm UTC](https://community.auth0.com/t/what-doesnt-namespace-refer-to-in-this-example/70575/1 "2021-09-30T19:50:55Z")

</div>

In the following example taken from [Auth0 docs](https://auth0.com/docs/authorization/authorization-policies/sample-use-cases-rules-with-authorization#add-user-roles-to-tokens) what does the name space refer to, and how do I know what it is in my configuration/setup?

```javascript
function (user, context, callback) {
  const namespace = 'http://demozero.net';
  const assignedRoles = (context.authorization || {}).roles;

  let idTokenClaims = context.idToken || {};
  let accessTokenClaims = context.accessToken || {};

  idTokenClaims[`${namespace}/roles`] = assignedRoles;
  accessTokenClaims[`${namespace}/roles`] = assignedRoles;

  context.idToken = idTokenClaims;
  context.accessToken = accessTokenClaims;

  callback(null, user, context);
}

```

---

<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:** [September 30, 2021, 7:59pm UTC](https://community.auth0.com/t/what-doesnt-namespace-refer-to-in-this-example/70575/3 "2021-09-30T19:59:29Z")

</div>

Hi @brett2,

Using a namespace prevents custom claims from colliding with standard claims. The name space you use is up to you as long as you follow some specific guidelines. In short, it helps to differentiate the claims you are adding to the token versus the standard claims that are being added based on the spec.

This doc provides more information as well as the necessary guidelines:

> **[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:** ![brett2](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brett2/32/22642_2.png) [@brett2](https://community.auth0.com/u/brett2)\
**Post date:** [September 30, 2021, 8:06pm UTC](https://community.auth0.com/t/what-doesnt-namespace-refer-to-in-this-example/70575/4 "2021-09-30T20:06:29Z")

</div>

Yeah, I see after using it it is a simply a name to use to customize the reference. It would be nice to have that in the docs, unless of corse I missed it (which is entirely possible).

Thank you Dan!

---

<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:** [September 30, 2021, 8:09pm UTC](https://community.auth0.com/t/what-doesnt-namespace-refer-to-in-this-example/70575/5 "2021-09-30T20:09:59Z")

</div>

Glad that was helpful. The doc I linked should cover everything I just mentioned, is there some way it could be more helpful?

---

<div class="post-metadata">

**Author:** ![brett2](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brett2/32/22642_2.png) [@brett2](https://community.auth0.com/u/brett2)\
**Post date:** [September 30, 2021, 8:28pm UTC](https://community.auth0.com/t/what-doesnt-namespace-refer-to-in-this-example/70575/6 "2021-09-30T20:28:12Z")

</div>

I guess the underlying issue is that from the reference of that example I don’t know what it’s doing and I didn’t see a reference on that page on were to figure out what it was for/didn’t know what to search for really. And I am a semi-experienced user of Auth0. Just not enough to remember all the pieces.

We are using this rule, and I was reviewing it. What I was seeing in my app vs. a client app wasn’t making sense, so I needed to find out.

Perhaps an output example of what the rule may be enough. Seeing how it was added to the identity token was all I needed to see to remember 🙂

Brett

---

<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:** [September 30, 2021, 8:29pm UTC](https://community.auth0.com/t/what-doesnt-namespace-refer-to-in-this-example/70575/7 "2021-09-30T20:29:55Z")

</div>

Thanks for the feedback! I’ll pass it to our docs team.

---

<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:** [December 23, 2021, 5:00pm UTC](https://community.auth0.com/t/what-doesnt-namespace-refer-to-in-this-example/70575/8 "2021-12-23T17:00:03Z")

</div>

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