# Custom client side custom JWT inputs

**URL:** <https://community.auth0.com/t/custom-client-side-custom-jwt-inputs/97936>\
**Category:** Get Help\
**Tags:** sdks-quickstarts, auth0-react\
**Created:** [January 11, 2023, 11:56am UTC](https://community.auth0.com/t/custom-client-side-custom-jwt-inputs/97936 "2023-01-11T11:56:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnWick](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/johnwick/32/42530_2.png) [@JohnWick](https://community.auth0.com/u/JohnWick)\
**Post date:** [January 11, 2023, 11:56am UTC](https://community.auth0.com/t/custom-client-side-custom-jwt-inputs/97936/1 "2023-01-11T11:56:24Z")

</div>

Hey !

Im trying to add a custom value to my JWT, I have the custom claims set up with the following code in auth0.

```auto
exports.onExecutePostLogin = async (event, api) => {

  const input = 'hello'

  if (event.authorization) {
    // Set claims 
    api.idToken.setCustomClaim(`input`, input);
  }
};

```

Which adds the variable input currently set to ‘hello’. I have also set up the action flow which works fine.

But what I want is to set a custom variable from the client side and set the variable input as that.

See how im making the JWT req below

```auto
    // getting user raw JWT token
    const accessToken = await getAccessTokenSilently({

      createJWT: {
        claims: {
          input: 'mockInputInput',
        },
        expiresIn: 3600,
      },
      detailedResponse: true, 
    
    })

    const clientJWT = accessToken.id_token
    console.log(clientJWT) // later add to deploy function for warp contract

    // Decode the JWT to see the claims
  const decodedToken = jwtDecode(clientJWT);
  console.log(decodedToken);

```

But I am still not getting the custom JWT claim input on the auth0 side

Please advise ! Thanks 🙂

---

<div class="post-metadata">

**Author:** ![JohnWick](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/johnwick/32/42530_2.png) [@JohnWick](https://community.auth0.com/u/JohnWick)\
**Post date:** [January 19, 2023, 5:13pm UTC](https://community.auth0.com/t/custom-client-side-custom-jwt-inputs/97936/2 "2023-01-19T17:13:51Z")

</div>

Hey !

Im trying to add custom variables to a JWT using the react auth0 SDK, but I want the front end req to specify the values.

I am making the req from the front end like:

```auto
const accessToken = await getAccessTokenSilently({
      detailedResponse: true,

      txn_data: '', // custom
      toContractId: '', // custom
      txn_data: '' // custom
      
    })

```

But the event.request.body has no data as well as the event.request.query does not contain these variables in the actions event.

Help, PLZ

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [January 19, 2023, 6:14pm UTC](https://community.auth0.com/t/custom-client-side-custom-jwt-inputs/97936/3 "2023-01-19T18:14:07Z")

</div>

Hi @JohnWick,

Thanks for reaching out to the Auth0 Community!

I see that you have made a post asking a similar question. I have merged them together for consistency.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [January 19, 2023, 6:29pm UTC](https://community.auth0.com/t/custom-client-side-custom-jwt-inputs/97936/4 "2023-01-19T18:29:47Z")

</div>

Hi @JohnWick,

> [@JohnWick](#):
>
> But what I want is to set a custom variable from the client side and set the variable input as that.
> 
> But I am still not getting the custom JWT claim input on the auth0 side

Yes, this is to be expected because the Access Token is generated from the authorization server (from Auth0). Moreover, Access Tokens are immutable, meaning they cannot be changed after it has been created.

The recommended way of appending custom claims to the access token is to use an Auth0 Post Login Action, as you have discovered.

I recommend checking out our [Adding custom claims to tokens](https://community.auth0.com/t/adding-custom-claims-to-tokens/84590) FAQ to learn more about appending custom claims to tokens.

Please let me know if you have any additional questions.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![tate](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tate/32/44064_2.png) [@tate](https://community.auth0.com/u/tate)\
**Post date:** [January 27, 2023, 5:26pm UTC](https://community.auth0.com/t/custom-client-side-custom-jwt-inputs/97936/5 "2023-01-27T17:26:51Z")

</div>

Hi Rueben,

I am having trouble getting this to work. I’m trying to set the value of a custom claim from my client (a single page application). Can you direct me on how to do this?

In other words, the custom claim needs to be variable and set programmatically by my application on a per-user basis.

Thanks,

Tate

---

<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:** [February 10, 2023, 5:26pm UTC](https://community.auth0.com/t/custom-client-side-custom-jwt-inputs/97936/6 "2023-02-10T17:26:55Z")

</div>

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