# Post login action not setting user metadata

**URL:** <https://community.auth0.com/t/post-login-action-not-setting-user-metadata/70037>\
**Category:** Get Help\
**Tags:** user\_metadata, login\
**Created:** [September 21, 2021, 3:56pm UTC](https://community.auth0.com/t/post-login-action-not-setting-user-metadata/70037 "2021-09-21T15:56:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paultipper](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/paultipper/32/31854_2.png) [@paultipper](https://community.auth0.com/u/paultipper)\
**Post date:** [September 21, 2021, 3:56pm UTC](https://community.auth0.com/t/post-login-action-not-setting-user-metadata/70037/1 "2021-09-21T15:56:13Z")

</div>

Hello,

I’m trying to use a post-login action to set a picture property within the user metadata. I’ve created and deployed the following action:

```auto
exports.onExecutePostLogin = async (event, api) => {
  api.user.setUserMetadata("picture", "https://db3pap007files.storage.live.com/y4mJQhpcRBjwDJkh5aIVjH95pD-085UxR5r1OyQX2-mNOCvqyjghcHimd6KXwSL2W5YeP_AhLN5r4GJYnfcm0SrJowroK4xAh0c8iNWuAiApICBJ9keaiIlAko19bkBqEIQnxJhJY2sQ6LktRppQJLaIaslG5gP9XqECzNqqAUaaxXE5DmBFzu_e3uwX4JebmF0?width=1200&height=1599&cropmode=none");
};

```

I then incorporated this custom action into the Login flow, between the Start and Complete stages:

 ![2021-09-21](https://global.discourse-cdn.com/auth0/original/3X/7/c/7c0ca3d954b7fc47b974671a459ce8325a11d906.png)

However, when I log into my SPA the getUser() method on the auth0 client, I’m not getting the user metadata:

```auto
const user = await auth0Client.getUser();

```

After this call, the **user** variable contains the basic attributes, e.g. nickname, name, email, etc., but does _not_ have a user metadata attribute.

Can anyone say what I’m doing wrong here or why the user metadata is not being returned?

I noticed that, in the template app from which I created my SPA, the call above was following by this comment:

```auto
      // Here you should extract the complete user profile to make it available in your entire app.
      // The auth state only provides basic information.

```

Is it the case that the getUser() method only returns a subset of the user profile, and if so, how can I get the complete profile?

---

<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:** [September 21, 2021, 11:05pm UTC](https://community.auth0.com/t/post-login-action-not-setting-user-metadata/70037/3 "2021-09-21T23:05:31Z")

</div>

Hi @paultipper,

Welcome to the Auth0 Community!

I understand that you have questions regarding user metadata.

First, I’d like to confirm that your Action works correctly and sets the picture in the user’s metadata.

Next, that’s correct. The `const user = await auth0Client.getUser();` returns the basic user profile attributes. You can see the full list here: [https://auth0.github.io/auth0-spa-js/classes/user.html](https://auth0.github.io/auth0-spa-js/classes/user.html), which does not include the `user_metadata` property.

In this situation, I recommend that you get the user’s email with `.getUser()` and [make a call to the Management API](https://auth0.com/docs/libraries/auth0-single-page-app-sdk#call-an-api) to the [`/get_users_by_email`](https://auth0.com/docs/api/management/v2#!/Users_By_Email/get_users_by_email) endpoint.

After doing so, you can filter for the user’s metadata from the results returned from the user profile as a JSON object.

Let me know if this addresses your problem.

Thank you.

---

<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:** [October 15, 2021, 7:39pm UTC](https://community.auth0.com/t/post-login-action-not-setting-user-metadata/70037/4 "2021-10-15T19:39:58Z")

</div>

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