# Need accessToken in Action to make additional Social calls to set app\_metadata?

**URL:** <https://community.auth0.com/t/need-accesstoken-in-action-to-make-additional-social-calls-to-set-app-metadata/97704>\
**Category:** Get Help\
**Tags:** app\_metadata, custom-social-connec, actions, access-token, auth0\
**Created:** [January 7, 2023, 11:03pm UTC](https://community.auth0.com/t/need-accesstoken-in-action-to-make-additional-social-calls-to-set-app-metadata/97704 "2023-01-07T23:03:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![2vYEjLFtkUPpbDR](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/2vyejlftkuppbdr/32/42395_2.png) [@2vYEjLFtkUPpbDR](https://community.auth0.com/u/2vYEjLFtkUPpbDR)\
**Post date:** [January 7, 2023, 11:03pm UTC](https://community.auth0.com/t/need-accesstoken-in-action-to-make-additional-social-calls-to-set-app-metadata/97704/1 "2023-01-07T23:03:47Z")

</div>

Hello!

Please help me figure out the process I should be following. I have created a Custom Social Connection for Twitch API as I needed additional scope that Auth0’s integration doesn’t have (it only has two very basic permissions).

 ![twcs](https://global.discourse-cdn.com/auth0/original/3X/e/d/eda38043bc952a1fc2390679efe40f69adb693ed.png)  
My current flow is:

1. User logs in with a Twitch account
2. Custom Social Connection
  - uses accessToken to fetch user account data from Twitch API
  - provides user account data to Auth0 so it can setup a user profile/record

Auth0’s normalised User Profile is limited, I want to store a few additional bits of user information that I get from making additional Twitch API calls. All Twitch API calls require a Bearer accessToken which are accessible in the Custom Social Connection page but it uses the normalised user model so I cannot store additional information from here, afaik.

I created a custom Post Login Action to store additional data in a user’s app\_metadata but I can’t make Twitch API calls from here as I don’t think I have the accessToken here.

Please advise on how I can make additional Twitch API calls for data and where I can store them. I think Auth0 is this extensible? It would be great to avoid setting up a database, syncing it with Auth0, etc just for one or two additional user properties.

Thank you 🙂

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [January 13, 2023, 1:18am UTC](https://community.auth0.com/t/need-accesstoken-in-action-to-make-additional-social-calls-to-set-app-metadata/97704/3 "2023-01-13T01:18:50Z")

</div>

Hey there @2vYEjLFtkUPpbDR welcome to the community!

Have you been able to make any progress on this?

> [@2vYEjLFtkUPpbDR](#):
>
> I created a custom Post Login Action to store additional data in a user’s app\_metadata but I can’t make Twitch API calls from here as I don’t think I have the accessToken here.

I’m not positive I follow your use case entirely, but perhaps the following topic may be of use:

> [@How do I call my API from an Action?](https://community.auth0.com/t/how-do-i-call-my-api-from-an-action/69041):
>
> Hey, So I’m in the process of trying to add a user to my database using an API call from a “Post User Registration” Action. I have followed this blog post here: and seem to have everything looking good. On top of that when I run the test it says the action was successful. The only problem is that my API is not being called at all even though I have triple checked that the URL is correct. Here is the code I’m working with: import axios from "axios"; exports.onExecutePostUserRegistration = …

Thinking out loud here, perhaps you could use the [Management API](https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id) elsewhere to add the requisite metadata?

Keep us posted!

---

<div class="post-metadata">

**Author:** ![2vYEjLFtkUPpbDR](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/2vyejlftkuppbdr/32/42395_2.png) [@2vYEjLFtkUPpbDR](https://community.auth0.com/u/2vYEjLFtkUPpbDR)\
**Post date:** [January 17, 2023, 11:46pm UTC](https://community.auth0.com/t/need-accesstoken-in-action-to-make-additional-social-calls-to-set-app-metadata/97704/4 "2023-01-17T23:46:30Z")

</div>

> [@ty.frith](#):
>
> I’m not positive I follow your use case entirely, but perhaps the following topic may be of use:

As I understand it, app\_metadata is used to store additional data. I want to store additional data about the user e.g. is the Twitch user logging in through the Custom Social Connection subscribed to a specific channel, and if they are a moderator for a specific channel, stored as booleans.

To get these additional bits of data I need to make two API calls to the Twitch API. These routes are protected and require sending an accessToken that is provided to the user after logging in.

I can’t do it using Actions or Rules since the accessToken given to the user when they log in through the Custom Social Connection is not available in Actions or Rules.

I can make the API calls in the Custom Social Connection’s “Fetch User Profile” code section but app\_metadata is not accessible from here. I can only store data in the format that Auth0’s normalised User Profile uses. And for some reason I can’t set e.g. nickname (a normalised property I don’t need since I have the email or user id) to a coded string such as “tf” to be used as true and false for the boolean examples in my first paragraph of this post.

---

<div class="post-metadata">

**Author:** ![2vYEjLFtkUPpbDR](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/2vyejlftkuppbdr/32/42395_2.png) [@2vYEjLFtkUPpbDR](https://community.auth0.com/u/2vYEjLFtkUPpbDR)\
**Post date:** [January 18, 2023, 5:41pm UTC](https://community.auth0.com/t/need-accesstoken-in-action-to-make-additional-social-calls-to-set-app-metadata/97704/5 "2023-01-18T17:41:53Z")

</div>

From my limited knowledge, I don;t think it;s possible using Auth0 at the moment/

I need one of these things to happen:

- Let us set app\_metadata in the Custom Social Connection login custom code section  
Or
- Give us access to the accessToken returned by a Custom Social Connection in Rules/Actions  
Or
- Similar to the first solution, give us more control over the data that we can save to an Auth0 User Profile model

This makes me ask, what is the point of a Custom Social Connection if you can’t save additional custom user/app data from that Custom Social Connection. Any valuable third party login and API will have protected routes that need an accessToken to retrieve scope/claims data. There is currently no way to save this data?

---

<div class="post-metadata">

**Author:** ![2vYEjLFtkUPpbDR](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/2vyejlftkuppbdr/32/42395_2.png) [@2vYEjLFtkUPpbDR](https://community.auth0.com/u/2vYEjLFtkUPpbDR)\
**Post date:** [January 23, 2023, 6:28pm UTC](https://community.auth0.com/t/need-accesstoken-in-action-to-make-additional-social-calls-to-set-app-metadata/97704/6 "2023-01-23T18:28:09Z")

</div>

@ty.frith Hey, sorry to bump you, would you happen to know if any of the above is possible? Is this something I can use Auth0 for? Thank you.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [January 23, 2023, 6:54pm UTC](https://community.auth0.com/t/need-accesstoken-in-action-to-make-additional-social-calls-to-set-app-metadata/97704/7 "2023-01-23T18:54:10Z")

</div>

Hey there @2vYEjLFtkUPpbDR sorry for the delayed response!

> [@2vYEjLFtkUPpbDR](#):
>
> This makes me ask, what is the point of a Custom Social Connection if you can’t save additional custom user/app data from that Custom Social Connection. Any valuable third party login and API will have protected routes that need an accessToken to retrieve scope/claims data. There is currently no way to save this data?

You’re correct in that the access token won’t be available until the login flow (and action(s)) is complete, but you will have access to the token in the [user’s identities array](https://auth0.com/docs/api/management/v2#!/Users/get_users). I don’t see why you couldn’t use the access token available on the user to get those details and add them to metadata outside the scope of an action.

> **[Identity Provider Access Tokens](https://auth0.com/docs/secure/tokens/access-tokens/identity-provider-access-tokens)**
>
> Understand third-party access tokens issued by identity providers after user authentication and how to use them to call the third-party APIs.

In terms of then getting that on login once set, you’d probably want to add metadata as a custom claim:

> [@How do I get User Metadata in the Login](https://community.auth0.com/t/how-do-i-get-user-metadata-in-the-login/71465/2):
>
> Hey @solid, The reason you didn’t receive the user’s metadata is because metadata is not a standard claim so it will not be included in ID Tokens by default. To include it, you must write a Rule to copy user\_metadata properties to the ID token. This is explained in detail here: [Add custom claims to a token](https://auth0.com/docs/configure/apis/scopes/sample-use-cases-scopes-and-claims#add-custom-claims-to-a-token). I hope this helps. More information:

Let us know if this helps!

---

<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:** [December 22, 2023, 11:56pm UTC](https://community.auth0.com/t/need-accesstoken-in-action-to-make-additional-social-calls-to-set-app-metadata/97704/8 "2023-12-22T23:56:31Z")

</div>

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