# Setting scope in access\_token breaks id\_token

**URL:** <https://community.auth0.com/t/setting-scope-in-access-token-breaks-id-token/8965>\
**Category:** Get Help\
**Tags:** bug-in-auth0, access\_token, scope, id\_token\
**Created:** [December 13, 2017, 4:16pm UTC](https://community.auth0.com/t/setting-scope-in-access-token-breaks-id-token/8965 "2017-12-13T16:16:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gunnar.velle](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@gunnar.velle](https://community.auth0.com/u/gunnar.velle)\
**Post date:** [December 13, 2017, 4:16pm UTC](https://community.auth0.com/t/setting-scope-in-access-token-breaks-id-token/8965/1 "2017-12-13T16:16:47Z")

</div>

I have a single page application and a backend application both registered as clients in Auth0. The SPA uses implicit grant to get id\_token and access\_token from Auth0. Kong validates the access\_token and sends the request to the backend. The SPA sets scope “openid profile” and gets full profileinformation from Google. So far so good.

I need to set roles in the access\_token for the backend to read, and am doing this using a rule. The rule goes like this: context.accessToken.scope = ‘list’,‘of’,‘roles’]; The problem now is the profile information disappears from the id\_token when the rule is active, and I only get basic information in the JWT. I found a way around this, by getting the scopes from the request and adding them to the scopes in the access\_token.

```
var roles = 'list','of','roles'];
var scope = context.request.query.scope || "";
context.accessToken.scope = roles.join(' ').concat(' ').concat(scope);

```

I would say this must be a bug in Auth0. Setting scope in access\_token should not affect how the id\_token is generated. I have searched the docs but have not been able to find where this behaviour is documented. If this is expected, please show me where this is described.

---

<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:** [December 21, 2017, 9:21pm UTC](https://community.auth0.com/t/setting-scope-in-access-token-breaks-id-token/8965/2 "2017-12-21T21:21:02Z")

</div>

I would have to check a few things first so I’m not providing this as an answer at this time, but technically when you perform an OpenID Connect implicit grant with `id_token token` the access token is also related to OIDC so setting the scope can be seen as denying the OIDC scopes that were requested. In particular, the access token would be used to perform calls to OIDC defined `/userinfo` endpoint. There is a small caveat that if the request is also for OAuth 2.0 authorization with a custom API and that API requires HS256 then the access token is not allowed for user info.

---

<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:57am UTC](https://community.auth0.com/t/setting-scope-in-access-token-breaks-id-token/8965/3 "2018-03-02T05:57:46Z")

</div>


