# Additional info in the generated JWT token

**URL:** <https://community.auth0.com/t/additional-info-in-the-generated-jwt-token/49982>\
**Category:** Get Help\
**Created:** [September 17, 2020, 10:07pm UTC](https://community.auth0.com/t/additional-info-in-the-generated-jwt-token/49982 "2020-09-17T22:07:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![henreman](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/henreman/32/13404_2.png) [@henreman](https://community.auth0.com/u/henreman)\
**Post date:** [September 17, 2020, 10:07pm UTC](https://community.auth0.com/t/additional-info-in-the-generated-jwt-token/49982/1 "2020-09-17T22:07:22Z")

</div>

Hi There,

I would like to pass additional info (session-specific) when requesting a POST to Auth0 to generate a token.

This is for a machine-to-machine request.

I would like this additional info to be included in the generated JWT token.

How can I do that in Auth0?

Thanks in advance 🙂

h

---

<div class="post-metadata">

**Author:** ![sidharth.chaudhary](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sidharth.chaudhary/32/20686_2.png) [@sidharth.chaudhary](https://community.auth0.com/u/sidharth.chaudhary)\
**Post date:** [September 17, 2020, 10:43pm UTC](https://community.auth0.com/t/additional-info-in-the-generated-jwt-token/49982/2 "2020-09-17T22:43:40Z")

</div>

Hey @henreman, Welcome to the Auth0 Community!

m2m grant or client credential grants have a way to customize/add information in tokens and i.e using Hooks!  
More information here:

> **[Customize Tokens Using Hooks with Client Credentials Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/customize-tokens-using-hooks-with-client-credentials-flow)**
>
> Learn how to use Hooks to change scopes and add custom claims in the access token obtained using the Client Credentials Flow.

Check this out and let me know how you go!

Regards,  
Sidharth

---

<div class="post-metadata">

**Author:** ![henreman](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/henreman/32/13404_2.png) [@henreman](https://community.auth0.com/u/henreman)\
**Post date:** [September 17, 2020, 11:10pm UTC](https://community.auth0.com/t/additional-info-in-the-generated-jwt-token/49982/3 "2020-09-17T23:10:46Z")

</div>

Thanks Sidharth,

If I’m understanding correctly, the additional claims needs to be pushed through programmatically?

Is there a way to add additional claims to the generated JWT token just via plain REST POST call? (ie. via Postman)

Cheers,

h

---

<div class="post-metadata">

**Author:** ![sidharth.chaudhary](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sidharth.chaudhary/32/20686_2.png) [@sidharth.chaudhary](https://community.auth0.com/u/sidharth.chaudhary)\
**Post date:** [September 17, 2020, 11:27pm UTC](https://community.auth0.com/t/additional-info-in-the-generated-jwt-token/49982/4 "2020-09-17T23:27:18Z")

</div>

hey @henreman, No the rest api call directly does not provide this functionality.  
To customize the access token for m2m this is the only current flow.

> **[Call Your API Using the Client Credentials Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/call-your-api-using-the-client-credentials-flow)**
>
> Learn how to call your API from a machine-to-machine (M2M) application using the Client Credentials Flow.

---

<div class="post-metadata">

**Author:** ![henreman](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/henreman/32/13404_2.png) [@henreman](https://community.auth0.com/u/henreman)\
**Post date:** [September 17, 2020, 11:50pm UTC](https://community.auth0.com/t/additional-info-in-the-generated-jwt-token/49982/5 "2020-09-17T23:50:58Z")

</div>

Ah gotcha,

I have read through the “Create a Hook” guide and here’s the instruction I find:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/f/2/f22cb38a61bd2a2260ad177a18944798f30f7e7b.png)

I assume this code gets executed on say “Client Credentials Exchange”?

But how does the “caller” of this endpoint pass the additional claims? The example only shows hard-coded claims?

Cheers,

h

---

<div class="post-metadata">

**Author:** ![joseantonio.rey](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/joseantonio.rey/32/14670_2.png) [@joseantonio.rey](https://community.auth0.com/u/joseantonio.rey)\
**Post date:** [September 18, 2020, 10:21pm UTC](https://community.auth0.com/t/additional-info-in-the-generated-jwt-token/49982/6 "2020-09-18T22:21:14Z")

</div>

@henreman You have to bear in mind that JWTs are immutable. This means that, after they have been issued, **there is no way to edit a JWT token without invalidating it**.

The Client Credentials hook allows you to allow extra claims to the token before it’s issued, enriching it with either a hardcoded value, or a value that you gather from any of the objects available within the hook (`context`, for example). The Hook does allow for Javascript code, which you can leverage to work around the `context` and maybe add conditionals, but there is no way to change the token once it has been issued.

Do you have an example of information that you would like to add to the token, that could not be gathered before the token is issued?

---

<div class="post-metadata">

**Author:** ![henreman](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/henreman/32/13404_2.png) [@henreman](https://community.auth0.com/u/henreman)\
**Post date:** [September 20, 2020, 10:48pm UTC](https://community.auth0.com/t/additional-info-in-the-generated-jwt-token/49982/7 "2020-09-20T22:48:35Z")

</div>

@joseantonio.rey thanks for the input.

I am trying to add claims to the token before it is being generated, not after.

I have had experience generating JWT tokens manually in the .NET world using Microsoft JWT library and we were able to attach any number of claims before the token is generated.

I am wondering the same for how can I do that in Auth0.

In the code sample above, it doesn’t say how a client of Auth0 can pass additional claims to be included in the token; the example only showed hard-coded ones.

Cheers,

h

---

<div class="post-metadata">

**Author:** ![joseantonio.rey](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/joseantonio.rey/32/14670_2.png) [@joseantonio.rey](https://community.auth0.com/u/joseantonio.rey)\
**Post date:** [September 21, 2020, 12:54am UTC](https://community.auth0.com/t/additional-info-in-the-generated-jwt-token/49982/8 "2020-09-21T00:54:00Z")

</div>

Hello, @henreman,

We do not have any written examples of this, but you could include additional parameters in the body of your `POST` request, and then check for them in the Hook using the `context.body` object. For example, I added a `testing` key with a value of `123`, and my Hook returned `context.body.testing` had a value of `123`. You could then use that `context.body.youradditionalvalue` value in order to enrich the token like in the example, instead of using the `bar` value.
