# I can't get my custom claim in my idToken

**URL:** <https://community.auth0.com/t/i-cant-get-my-custom-claim-in-my-idtoken/107373>\
**Category:** Get Help\
**Tags:** user-profile, user-management\
**Created:** [May 19, 2023, 9:53am UTC](https://community.auth0.com/t/i-cant-get-my-custom-claim-in-my-idtoken/107373 "2023-05-19T09:53:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![florian.drevet](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@florian.drevet](https://community.auth0.com/u/florian.drevet)\
**Post date:** [May 19, 2023, 9:53am UTC](https://community.auth0.com/t/i-cant-get-my-custom-claim-in-my-idtoken/107373/1 "2023-05-19T09:53:23Z")

</div>

Hello,  
I’m new to using Auth0 and I’m having trouble adding custom claims. I’ve written a post-login rule in my authentication flow like this:

```auto
exports.onExecutePostLogin = async (event, api) => {
if (event.stats.logins_count === 1) {
  const axios = require("axios")
    
    // Définir les paramètres de la requête
    const userData = {
        firstName: event.user.user_metadata.user_firstname,
        lastName: event.user.user_metadata.user_name,
        email: event.user.email
    }
    // Faire la requête HTTP
   try {
      const response = await axios.post('https://-my-api-/api/User/', userData);
      api.user.setUserMetadata("idUser", response.data);
      api.idToken.setCustomClaim("https://-domain-/idUser", response.data.idUser)
    } catch (error) {
      console.error('Error during POST request:', error);
    }
  }
  else {
      api.idToken.setCustomClaim("https://-domain-/idUser", event.user.user_metadata.idUser)
  }
};

```

Then, I’m trying to retrieve it in my Angular application like this:

```auto
this.authService.idTokenClaims$.subscribe(v => {
      console.log(v)
    })

```

However, the field doesn’t appear… I’m unable to retrieve it. Does anyone have any ideas on how to do it, please?

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [May 19, 2023, 10:52am UTC](https://community.auth0.com/t/i-cant-get-my-custom-claim-in-my-idtoken/107373/2 "2023-05-19T10:52:54Z")

</div>

Hey there!

We are nearing the support of Rule in our stack so I would encourage you to utilise Actions. Here’s a step by step tutorial on how to use Actions to add custom claims to ID Token:

> **[Adding Custom Claims to ID Tokens with Auth0 Actions](https://auth0.com/blog/adding-custom-claims-to-id-token-with-auth0-actions/)**
>
> Learn how to create a new custom Action that will add a custom claim to your Auth0-issued ID Token

---

<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:** [June 2, 2023, 10:53am UTC](https://community.auth0.com/t/i-cant-get-my-custom-claim-in-my-idtoken/107373/3 "2023-06-02T10:53:07Z")

</div>

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