# Can' retrieve user meta data using the @auth0/auth0-angular library and Auth0 Actions

**URL:** <https://community.auth0.com/t/can-retrieve-user-meta-data-using-the-auth0-auth0-angular-library-and-auth0-actions/105145>\
**Category:** Get Help\
**Tags:** login-prompt-new-experience, login-experience\
**Created:** [April 20, 2023, 10:30am UTC](https://community.auth0.com/t/can-retrieve-user-meta-data-using-the-auth0-auth0-angular-library-and-auth0-actions/105145 "2023-04-20T10:30:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark1987](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@mark1987](https://community.auth0.com/u/mark1987)\
**Post date:** [April 20, 2023, 10:30am UTC](https://community.auth0.com/t/can-retrieve-user-meta-data-using-the-auth0-auth0-angular-library-and-auth0-actions/105145/1 "2023-04-20T10:30:40Z")

</div>

Hi,

I’m able to login and signup to my Auth0 forms.

I’ve been able to add custom meta data on the sign up form such as “first\_name”.

I would like my Angular app to receive “first\_name” in the user object that I’m listening to after login.

**Example of my login code:**

```auto
this.authService.user$.subscribe((user: any) => {
      if (user) {
        console.log(user);
        const test1 = user['http://localhost:4200/first_name'];
        console.log(test1);
      }
    })

```

I see the user object but no first\_name.  
The user I login with has first\_name able as meta\_data (which I see populated in user management).

Next I made a new action called user-meta-action and deployed it / added to the login flow diagram.

**This is my action code in Auth0:**

```auto
exports.onExecutePostLogin = async (event, api) => {
  const namespace = 'http://localhost:4200/';
  const { first_name } = event.user.user_metadata;

  if (event.authorization) {
    api.user.setUserMetadata(`${namespace}/first_name`, first_name);
  }
};

```

**Issue:**

I think the issue I’m having is I don’t know what to set **namespace** to in the action code?  
Furthermore, I’m unsure if my angular code is correct for calling the first\_name claim.

I’ve checked the logs and it seems the action is firing but no user data being return.  
Weirdly the data shows in the actions test play if I hard code first\_name to like dave.  
However, that doesn’t show either in the logs.

Logs:

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

Action test (just trying to get it working with dave hard coded):

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

I look forward to your response.

---

<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:** [April 24, 2023, 1:35pm UTC](https://community.auth0.com/t/can-retrieve-user-meta-data-using-the-auth0-auth0-angular-library-and-auth0-actions/105145/3 "2023-04-24T13:35:20Z")

</div>

Hi @mark1987,

Welcome to the Auth0 Community!

You need to set the metadata as a custom claim in the token. [Here is an example of how to add a custom claim to the token](https://auth0.com/docs/get-started/apis/scopes/sample-use-cases-scopes-and-claims#add-custom-claims-to-a-token).

Setting the info with `setUserMetadata` only adds it to the user object _inside of Auth0_. It isn’t automatically returned in the token.

Hope that helps!

---

<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 8, 2023, 1:36pm UTC](https://community.auth0.com/t/can-retrieve-user-meta-data-using-the-auth0-auth0-angular-library-and-auth0-actions/105145/4 "2023-05-08T13:36:00Z")

</div>

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