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


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:

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

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:

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);


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.


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

I look forward to your response.

1 Like

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.

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!

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