# User.app\_metadata not available when subscribing to user$

**URL:** <https://community.auth0.com/t/user-app-metadata-not-available-when-subscribing-to-user/62390>\
**Category:** Get Help\
**Tags:** auth0-angular\
**Created:** [May 7, 2021, 9:52am UTC](https://community.auth0.com/t/user-app-metadata-not-available-when-subscribing-to-user/62390 "2021-05-07T09:52:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thenetimp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thenetimp/32/21335_2.png) [@thenetimp](https://community.auth0.com/u/thenetimp)\
**Post date:** [May 7, 2021, 9:52am UTC](https://community.auth0.com/t/user-app-metadata-not-available-when-subscribing-to-user/62390/1 "2021-05-07T09:52:31Z")

</div>

I have an Angular11 application that I have integrated Auth0-angular library into. I have also created a rule that on login checks to see if user.app\_metadata.stripe\_customer exists, if it doesn’t exist it then goes about creating a stripe customer with stripes API, a stripe subscription and attaching it to that customer, and then updating user.app\_metadata with the stripe customer information. If the stripe\_customer exists it will grab the latest information from stripe and update user.app\_metadata.stripe\_customer with the new data. This functionality works.

I now want to make use of this user.app\_metadata in my application. For example, show a user when their subscription ends, or if it has ended redirect them to a page to purchase a new paid subscription. However the code to get the user

```auto
    this.auth.user$.subscribe(user => {
      console.log(user);
      console.log(user.app_metadata);
    });

```

When I register or login. user.app\_metadata does not exist, and looking through the documentation I don’t see any way within the Auth0-angular library to get this data. Could someone point me in the right direction?

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [May 7, 2021, 11:19am UTC](https://community.auth0.com/t/user-app-metadata-not-available-when-subscribing-to-user/62390/3 "2021-05-07T11:19:00Z")

</div>

Hi @thenetimp,

The user object that the Angular SDK exposes is the decoded ID token. Here’s an example of profile info that would be included in an ID Token: [ID Token Structure](https://auth0.com/docs/tokens/id-tokens/id-token-structure)

You can extend the data that is included in the ID Token by adding this to your rule:

```auto
function(user, context, callback) {
  // ... handle stripe customer logic
  const namespace = 'https://myapp.example.com/';
  context.idToken[namespace + 'stripe_customer'] = user.app_metadata.stripe_customer; // You could also include all of app_metadata instead
  callback(null, user, context);
}

```

In your Angular app, you can retrieve the custom claim like this:

```auto
    this.auth.user$.subscribe(user => {
      console.log(user['https://myapp.example.com/stripe_customer']);
    });

```

Here is more information about adding custom claims:

> **[Sample Use Cases: Scopes and Claims](https://auth0.com/docs/get-started/apis/scopes/sample-use-cases-scopes-and-claims)**
>
> Learn how to use scopes and claims with applications and APIs.

---

<div class="post-metadata">

**Author:** ![thenetimp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thenetimp/32/21335_2.png) [@thenetimp](https://community.auth0.com/u/thenetimp)\
**Post date:** [May 7, 2021, 11:35am UTC](https://community.auth0.com/t/user-app-metadata-not-available-when-subscribing-to-user/62390/4 "2021-05-07T11:35:29Z")

</div>

I was just coming here to reply to my own ticket, cause I had just figured that out on my own. Thanks for replying in a quick manner though.

---

<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 22, 2021, 11:36am UTC](https://community.auth0.com/t/user-app-metadata-not-available-when-subscribing-to-user/62390/5 "2021-05-22T11:36:23Z")

</div>

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