# Hooks and id\_token

**URL:** <https://community.auth0.com/t/hooks-and-id-token/41691>\
**Category:** JWT.io\
**Created:** [April 24, 2020, 6:53am UTC](https://community.auth0.com/t/hooks-and-id-token/41691 "2020-04-24T06:53:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alain.bodiguel](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/alain.bodiguel/32/14378_2.png) [@alain.bodiguel](https://community.auth0.com/u/alain.bodiguel)\
**Post date:** [April 24, 2020, 6:53am UTC](https://community.auth0.com/t/hooks-and-id-token/41691/1 "2020-04-24T06:53:54Z")

</div>

Hi, I’m using a rule to enrich my id\_token with a “$namespace/permissions” claim.  
How can I do the same with a hook: using client credentials grant, my application expects to find the claim in order to validate the authorization.

Thank you in advance,

---

<div class="post-metadata">

**Author:** ![mathiasconradt](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mathiasconradt/32/12758_2.png) [@mathiasconradt](https://community.auth0.com/u/mathiasconradt)\
**Post date:** [April 24, 2020, 7:43am UTC](https://community.auth0.com/t/hooks-and-id-token/41691/2 "2020-04-24T07:43:08Z")

</div>

Where do these permissions come from? Are you using Auth0’s [RBAC core](https://auth0.com/docs/authorization/concepts/rbac) feature?  
Another question: why do you need the permissions in the ID token and not the access token?

This might be a helpful post:

> [@Difference between scopes and permissions in access token](http://community.auth0.com/t/difference-between-scopes-and-permissions-in-access-token/28900/5):
>
> Update 11/May/2020: For M2M / Client Credentials Grant, the permissions for a M2M client is put in both scope and permissions claim. I’ve tested it and it works as expected, so the approach below should not be necessary anymore. Original answer: I might have missed some DMs in between, but even with the RBAC Core (not Authorization extension - doesn’t actually make a difference): I was able to reproduce the behaviour described by the OP. In M2M settings, the scopes set for a client for acce…

---

<div class="post-metadata">

**Author:** ![alain.bodiguel](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/alain.bodiguel/32/14378_2.png) [@alain.bodiguel](https://community.auth0.com/u/alain.bodiguel)\
**Post date:** [April 24, 2020, 8:32am UTC](https://community.auth0.com/t/hooks-and-id-token/41691/3 "2020-04-24T08:32:14Z")

</div>

The permissions come from RBAC indeed.  
With my SPA app, I read the id\_token to get the permissions (am I doing that right?).  
With the M2M, you’re saying I can rely on the access\_token to get the permissions? I can see indeed a claim “permissions” in it but it is missing my namespace. If I understang correctly the post you’ve quoted I should be able to enrich the access\_token on my M2M app with a hook.

`access_token['https://namespace/permissions'] = scope;`

Ok, I’ve tried adding the following hook, and it does what I need. Thank you for your quick and efficient response!

---

<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:** [May 9, 2020, 8:32am UTC](https://community.auth0.com/t/hooks-and-id-token/41691/4 "2020-05-09T08:32:17Z")

</div>

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