# Is it possible to create a rule to avoid specifying multiple scopes for authentication requests?

**URL:** <https://community.auth0.com/t/is-it-possible-to-create-a-rule-to-avoid-specifying-multiple-scopes-for-authentication-requests/6177>\
**Category:** Get Help\
**Tags:** rules, id\_token, scopes\
**Created:** [April 11, 2017, 2:57am UTC](https://community.auth0.com/t/is-it-possible-to-create-a-rule-to-avoid-specifying-multiple-scopes-for-authentication-requests/6177 "2017-04-11T02:57:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vandriotti](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@vandriotti](https://community.auth0.com/u/vandriotti)\
**Post date:** [April 11, 2017, 2:57am UTC](https://community.auth0.com/t/is-it-possible-to-create-a-rule-to-avoid-specifying-multiple-scopes-for-authentication-requests/6177/1 "2017-04-11T02:57:30Z")

</div>

I’m trying to make a rule in Auth0 to avoid specifying multiple scopes for authentication requests.  
Basically, I want to specify one scope or provide no scope during authentication and respond with an `id_token` containing a default subset of the user profile. I found some rule documentation and managed to edit the scope query `context.request.query.scope.match(/\S+/g)` and also managed to set values into the `id_token` using `context.idToken'my_param] = user.my_param`.

Although it works through rule debugging UI, but it does not work when actually trying to authenticate.

Is it possible to accomplish this by making rule or using some other feature of Auth0? If not, is there another workflow we should use?

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [April 13, 2017, 5:31pm UTC](https://community.auth0.com/t/is-it-possible-to-create-a-rule-to-avoid-specifying-multiple-scopes-for-authentication-requests/6177/2 "2017-04-13T17:31:52Z")

</div>

Yes, that should be possible, the exact details would depend on the endpoints being used. The reason for this is that right now the authentication API can be called in a strict [OpenID Connect (OIDC) compliant mode](https://auth0.com/docs/api-auth/tutorials/adoption) and in a legacy mode that predated that specification in question.

You seem to be using the `context.idToken` approach which was made available for the OIDC mode which is the recommended mode to use so I’ll assume you be using this instead of the legacy mode for the remainder of my answer.

In this mode you can include arbitrary custom claims to the ID Token through a rule independently of the scope requested (your rule can still check the requested scope to add conditional logic, but the rule as the final saying). The requirement (documented [here](https://auth0.com/docs/api-auth/tutorials/adoption/scope-custom-claims#custom-claims)) is that you need to namespace your custom claims so that they don’t conflict with the ones defined in the specification, for example:

```
function (user, context, callback) {
  const namespace = 'https://myapp.example.com/';
  context.idToken[namespace + 'favorite_color'] = user.favorite_color;

  callback(null, user, context);
}

```

\_\_

If you want to ensure that you’re indeed making use of the OIDC mode check this [section](https://auth0.com/docs/api-auth/tutorials/adoption#terminology).

---

<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:** [March 2, 2018, 5:53am UTC](https://community.auth0.com/t/is-it-possible-to-create-a-rule-to-avoid-specifying-multiple-scopes-for-authentication-requests/6177/3 "2018-03-02T05:53:12Z")

</div>


