# Scopes missing from id\_token but present in access\_token

**URL:** <https://community.auth0.com/t/scopes-missing-from-id-token-but-present-in-access-token/6593>\
**Category:** Get Help\
**Tags:** id\_token\
**Created:** [May 12, 2017, 5:56am UTC](https://community.auth0.com/t/scopes-missing-from-id-token-but-present-in-access-token/6593 "2017-05-12T05:56:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikebridge](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mikebridge/32/10313_2.png) [@mikebridge](https://community.auth0.com/u/mikebridge)\
**Post date:** [May 12, 2017, 5:56am UTC](https://community.auth0.com/t/scopes-missing-from-id-token-but-present-in-access-token/6593/1 "2017-05-12T05:56:12Z")

</div>

I was able to add my scopes to my `access_token` with this rule excerpt:

```
  var requested_scopes_string = context.request.query.scope || '';
  var requested_scopes = requested_scopes_string.split(' ');
  var allowed_scopes = intersect(requested_scopes, 'openid', 'profile', 'email']);

  if(context.accessToken) {       
      context.accessToken.scope = allowed_scopes;
      roles.forEach(function(role) {
        context.accessToken.scope.push(role);
      });
  }   

```

However, they don’t appear in my idToken if I use the same code:

```
  if(context.idToken) {       
      context.idToken.scope = allowed_scopes;
      roles.forEach(function(role) {
        context.idToken.scope.push(role);
      });
  }   

```

I also tried this:

```
  user.app_metadata.roles = roles;
  auth0.users.updateAppMetadata(user.user_id, user.app_metadata)
    .then(function(){
      callback(null, user, context);
    })
    .catch(function(err){
      callback(err);
    });

```

I’m calling it with these parameters (among others):

```
oidcConformant: true,
responseType: "token id_token"
scope: "openid email profile api",

```

Any idea why the `id_token` / profile doesn’t give me the scopes back, even though the `access_token` does?

---

<div class="post-metadata">

**Author:** ![mikebridge](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mikebridge/32/10313_2.png) [@mikebridge](https://community.auth0.com/u/mikebridge)\
**Post date:** [May 12, 2017, 6:25am UTC](https://community.auth0.com/t/scopes-missing-from-id-token-but-present-in-access-token/6593/2 "2017-05-12T06:25:09Z")

</div>

… I still don’t know how to get it from the idToken, but I was able to parse the `access_token` with `jwt-decode` instead:

```
import * as decode from "jwt-decode";

export function scopes(token: string): string] {
    const decoded = decode(token);
    return !decoded.scope ? ] : decoded.scope.split(" ");
}

```

---

<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/scopes-missing-from-id-token-but-present-in-access-token/6593/3 "2018-03-02T05:53:52Z")

</div>


