# Trying to get app\_metadata from /userinfo endpoint

**URL:** <https://community.auth0.com/t/trying-to-get-app-metadata-from-userinfo-endpoint/48385>\
**Category:** Get Help\
**Tags:** app\_metadata, custom-claims, rules\
**Created:** [August 20, 2020, 1:38pm UTC](https://community.auth0.com/t/trying-to-get-app-metadata-from-userinfo-endpoint/48385 "2020-08-20T13:38:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nathleia.llc](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nathleia.llc/32/23686_2.png) [@nathleia.llc](https://community.auth0.com/u/nathleia.llc)\
**Post date:** [August 20, 2020, 1:38pm UTC](https://community.auth0.com/t/trying-to-get-app-metadata-from-userinfo-endpoint/48385/1 "2020-08-20T13:38:09Z")

</div>

I am trying to set things up to be able to get app\_metadata from the /userinfo endpoint. I have looked at topics in here as well as on StackOverflow and have been stymied and confused. Using Custom Claims looks like it does what I want. Here is what I have tried:

I created a rule and the code looks like this:

```
function (user, context, callback) {
var namespace = "https://myNamespace.com/";
user.app_metadata = user.app_metadata || {};
context.accessToken[namespace + "app_metadata"] = user.app_metadata; 
callback(null, user, context);
}

```

Testing the rule appears successful.

In Postman, I can hit ‘/oauth/token’ with a username and password and get an access\_token just fine. But when I hit ‘/userinfo?access\_token=\<access\_token\>’, this is my response:

```
 {
"sub": "auth0|5ef266faaba0300019ce0b26",
"nickname": "paul",
"name": "Paul",
"picture": "https://s.gravatar.com/avatar/f16f6aa3b000916dc48e6947660c201d?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fpa.png",
"updated_at": "2020-08-19T21:23:58.404Z",
"email": "nathleia.llc@gmail.com",
"email_verified": false

```

}

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [August 20, 2020, 3:23pm UTC](https://community.auth0.com/t/trying-to-get-app-metadata-from-userinfo-endpoint/48385/2 "2020-08-20T15:23:22Z")

</div>

You need to add the custom claim to the ID token; only custom claims added to the ID token will surface in `/userinfo`.

Replace `context.accessToken[namespace + "app_metadata"]` with `context.idToken[namespace + "app_metadata"]`.

---

<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 4, 2020, 3:23pm UTC](https://community.auth0.com/t/trying-to-get-app-metadata-from-userinfo-endpoint/48385/3 "2020-09-04T15:23:31Z")

</div>

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