# How to add custom data to a user according to his email

**URL:** <https://community.auth0.com/t/how-to-add-custom-data-to-a-user-according-to-his-email/69090>\
**Category:** Get Help\
**Tags:** login, auth0\
**Created:** [September 5, 2021, 8:17am UTC](https://community.auth0.com/t/how-to-add-custom-data-to-a-user-according-to-his-email/69090 "2021-09-05T08:17:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Insighting](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/insighting/32/12814_2.png) [@Insighting](https://community.auth0.com/u/Insighting)\
**Post date:** [September 5, 2021, 8:17am UTC](https://community.auth0.com/t/how-to-add-custom-data-to-a-user-according-to-his-email/69090/1 "2021-09-05T08:17:16Z")

</div>

Is there a way to attach some data to a user after he logged in ?  
I want to implement it somewhere after he press logged in and according to his credintials (email) it will find the applicable data to this user and pass it to me so inside the user object. |right now the user object holds :

1. email:
2. email\_verified:
3. family\_name:
4. given\_name:
5. locale:
6. name:
7. nickname:
8. picture:
9. sub:

how can i add to this object ?  
Thanks in Advance!

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [September 7, 2021, 5:17pm UTC](https://community.auth0.com/t/how-to-add-custom-data-to-a-user-according-to-his-email/69090/3 "2021-09-07T17:17:42Z")

</div>

Hi @Insighting,

> [@Insighting](#):
>
> Is there a way to attach some data to a user after he logged in ?

Yes, you can use [user\_metadata or app\_metadata](https://auth0.com/docs/users/metadata) to add information to the user’s profile.

> [@Insighting](#):
>
> I want to implement it somewhere after he press logged in and according to his credintials (email) it will find the applicable data to this user and pass it to me so inside the user object

In order to add the data to the user after they log in you should use a [post login action](https://auth0.com/docs/actions/triggers/post-login). You can add the data as a custom claim. To set custom claims in actions you can use the following methods:

```auto
api.idToken.setCustomClaim
api.accessToken.setCustomClaim

```

Let me know if you have any questions.

---

<div class="post-metadata">

**Author:** ![Insighting](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/insighting/32/12814_2.png) [@Insighting](https://community.auth0.com/u/Insighting)\
**Post date:** [September 9, 2021, 5:38am UTC](https://community.auth0.com/t/how-to-add-custom-data-to-a-user-according-to-his-email/69090/4 "2021-09-09T05:38:46Z")

</div>

Hi Dan,  
Thank you for the quick response, I added some metaData manually via the “User Management” tab under “users” yet, I cannot see the metaData inside the user object I am getting after authenticating =\>  
`const { user } = useAuth0();`  
I also tried this:

```plaintext
        const accessToken = await getAccessTokenSilently({
          audience: `https://${domain}/api/v2/`,
          // scope: "read:current_user",
        });

        const userDetailsByIdUrl = `https://${domain}/userinfo`;

        axios
          .get(userDetailsByIdUrl, {
            headers: {
              Authorization: `Bearer ${accessToken}`,
            },
          })
          .then((response) => {
            console.log(response.data);
          })
          .catch((error) => {
            console.log("ERROR API RESPONSE => ", error);
          });
      } catch (e) {
        console.log(e.message);
      }
    };

```

but I got the same exact user obect in response.

Where can i see the metaData?

In addition, why `https://${domain}/userinfo`; this request is getting through but any other request such as `https://${domain}/api/v2/users` returns 403 error

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [September 9, 2021, 4:00pm UTC](https://community.auth0.com/t/how-to-add-custom-data-to-a-user-according-to-his-email/69090/5 "2021-09-09T16:00:56Z")

</div>

> [@Insighting](#):
>
> I added some metaData manually via the “User Management” tab under “users” yet, I cannot see the metaData inside the user object I am getting after authenticating

You will need to use a rule to add the metadata to the token. The user object in your application is being pulled directly from the token. Here is an example rule that adds some metadata to the token:

[https://auth0.com/docs/configure/apis/scopes/sample-use-cases-scopes-and-claims#add-custom-claims-to-a-token](https://auth0.com/docs/configure/apis/scopes/sample-use-cases-scopes-and-claims#add-custom-claims-to-a-token)

> [@Insighting](#):
>
> In addition, why `https://${domain}/userinfo` ; this request is getting through but any other request such as `https://${domain}/api/v2/users` returns 403 error

The userinfo endpoint is available from SPA applications with a user’s token, the management API endpoints are not.

---

<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:** [September 24, 2021, 4:01pm UTC](https://community.auth0.com/t/how-to-add-custom-data-to-a-user-according-to-his-email/69090/6 "2021-09-24T16:01:04Z")

</div>

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