# Get app\_metadata Stored In Auth0 using Social Connection

**URL:** <https://community.auth0.com/t/get-app-metadata-stored-in-auth0-using-social-connection/113392>\
**Category:** Get Help\
**Tags:** connections-management-api, management-api\
**Created:** [August 10, 2023, 5:02pm UTC](https://community.auth0.com/t/get-app-metadata-stored-in-auth0-using-social-connection/113392 "2023-08-10T17:02:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![scottcp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/scottcp/32/41103_2.png) [@scottcp](https://community.auth0.com/u/scottcp)\
**Post date:** [August 10, 2023, 5:02pm UTC](https://community.auth0.com/t/get-app-metadata-stored-in-auth0-using-social-connection/113392/1 "2023-08-10T17:02:38Z")

</div>

I am sending a request, where I am returning the user’s app\_metadata and using that information for the login process. When I use a social connection like google, I don’t seem to can any app\_metadata in the JWT. Is there are way to return this?

> https://{mydomain}.auth0.com/authorize?audience=[https://auth](https://auth).{mydomain}&scope=openid%20profile%20read:users%20read:users\_app\_metadata%20offline\_access&response\_type=code&client\_id={myid}&prompt=login

---

<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:** [August 10, 2023, 5:46pm UTC](https://community.auth0.com/t/get-app-metadata-stored-in-auth0-using-social-connection/113392/3 "2023-08-10T17:46:15Z")

</div>

Hi @scottcp,

> [@scottcp](#):
>
> When I use a social connection like google, I don’t seem to can any app\_metadata in the JWT.

I have inspected the users on your tenant and found that your Google Connection user has nothing saved to their app\_metadata while other users have items saved in their app\_metadata.

That is why you have not been able to get the app\_metadata in your access token, even though you have a Rule that appends the app\_metadata to your access token as a custom claim.

With that, I recommend checking the Google Connection user profile and making sure it has data saved to the app\_metadata.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![scottcp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/scottcp/32/41103_2.png) [@scottcp](https://community.auth0.com/u/scottcp)\
**Post date:** [August 10, 2023, 9:01pm UTC](https://community.auth0.com/t/get-app-metadata-stored-in-auth0-using-social-connection/113392/4 "2023-08-10T21:01:14Z")

</div>

Hi Rueben,

Thanks for your response. Is it possible to use the app metadata from Auth0 rather than from the other social providers? It’s all going to be the same data so it seems like duplication to spread it across providers.

If I absolutely need to save the app metadata on each provider everytime I add them can you point me to the best way to do that?

Thanks,  
Scott

---

<div class="post-metadata">

**Author:** ![scottcp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/scottcp/32/41103_2.png) [@scottcp](https://community.auth0.com/u/scottcp)\
**Post date:** [August 15, 2023, 4:55pm UTC](https://community.auth0.com/t/get-app-metadata-stored-in-auth0-using-social-connection/113392/6 "2023-08-15T16:55:29Z")

</div>

> Hi @scottcp, I have inspected the users on your tenant and found that your Google Connection user has nothing saved to their app\_metadata while other users have items saved in their app\_metadata. That is why you have not been able to get the app\_metadata in your access token, even though you have

I think I am really looking for a way to copy the app\_metadata from the Username-Password-Authentication to the social logins when they are created. Is that possible to do?

---

<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:** [August 16, 2023, 8:51pm UTC](https://community.auth0.com/t/get-app-metadata-stored-in-auth0-using-social-connection/113392/7 "2023-08-16T20:51:37Z")

</div>

Hi @scottcp,

Thanks for following up.

> [@scottcp](#):
>
> I think I am really looking for a way to copy the app\_metadata from the Username-Password-Authentication to the social logins when they are created. Is that possible to do?

Yes, this is possible. For this to work, you could update the user’s metadata for Social Connections on their first login. Take note that whenever a user signs up, they are logged in immediately as well. Knowing this, you could write a Post-Login Action script that checks that the user’s connection is a social connection and that their logins\_count is equal to 1 and then use the `api.user.setUserMetadata(name, value)` method in the Action to update the user’s metadata. (Reference: [Actions Triggers: post-login - API Object](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow/api-object#:~:text=api.user.setUserMetadata(name%2C%20value)))

Please let me know if you need help with implementation.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![scottcp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/scottcp/32/41103_2.png) [@scottcp](https://community.auth0.com/u/scottcp)\
**Post date:** [August 16, 2023, 9:53pm UTC](https://community.auth0.com/t/get-app-metadata-stored-in-auth0-using-social-connection/113392/8 "2023-08-16T21:53:42Z")

</div>

Thanks, Rueben!  
From what I can see the first time a social connection is used it will create a social login, how will I be able to read the app\_metadata from the user with the same email address already has a Username-Password-Authentication? This is where I remain stuck.

---

<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:** [August 16, 2023, 10:31pm UTC](https://community.auth0.com/t/get-app-metadata-stored-in-auth0-using-social-connection/113392/9 "2023-08-16T22:31:27Z")

</div>

Hi @scottcp,

> [@scottcp](#):
>
> how will I be able to read the app\_metadata from the user with the same email address already has a Username-Password-Authentication?

You will have to use the Management API in the Action to make a call to the [getUsersByEmail()](https://auth0.github.io/node-auth0/ManagementClient.html#getUsersByEmail) method to get the user’s user\_metadata with the same email address. Then save that information to the Social Connection user using the `api.user.setUserMetadata(name, value)` method.

It may be worth considering [User Account Linking](https://auth0.com/docs/manage-users/user-accounts/user-account-linking) so that the user’s multiple profiles are consolidated as one.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![scottcp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/scottcp/32/41103_2.png) [@scottcp](https://community.auth0.com/u/scottcp)\
**Post date:** [August 17, 2023, 5:50pm UTC](https://community.auth0.com/t/get-app-metadata-stored-in-auth0-using-social-connection/113392/10 "2023-08-17T17:50:00Z")

</div>

Thanks those are some great suggestions. I’m having a little trouble getting the mangement api into the actions. Do you have any examples? I’ve tried code like this and I’m getting errors.

```auto
exports.onExecutePostLogin = async (event, api) => {
  const { MGMT_DOMAIN, MGMT_ID, MGMT_SECRET } = event.secrets;
    const ManagementClient = require('auth0').ManagementClient;
    var management = new ManagementClient({
        domain: MGMT_DOMAIN,
        clientId: MGMT_ID,
        clientSecret: MGMT_SECRET,
    });
    ManagementClient.auth0.getUsersByEmail(event.user.email, function (err, users) {
  api.accessToken.setCustomClaim(`hello world`, users);
});
};

```

---

<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:** [August 17, 2023, 6:02pm UTC](https://community.auth0.com/t/get-app-metadata-stored-in-auth0-using-social-connection/113392/11 "2023-08-17T18:02:33Z")

</div>

Hi @scottcp,

Thanks for the reply!

Yes, I have attached a link below on how to use the Management API in Actions:  
[https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947](https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947)

Could you please give it a try and let me know how it goes for you?

Thanks,  
Rueben

---

<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:** [August 31, 2023, 6:03pm UTC](https://community.auth0.com/t/get-app-metadata-stored-in-auth0-using-social-connection/113392/12 "2023-08-31T18:03:28Z")

</div>

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