# Need to call discord API with auth token to retrieve additional info

**URL:** <https://community.auth0.com/t/need-to-call-discord-api-with-auth-token-to-retrieve-additional-info/101180>\
**Category:** Get Help\
**Tags:** configuration, application\
**Created:** [February 23, 2023, 8:01pm UTC](https://community.auth0.com/t/need-to-call-discord-api-with-auth-token-to-retrieve-additional-info/101180 "2023-02-23T20:01:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nanaki658](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nanaki658/32/39337_2.png) [@nanaki658](https://community.auth0.com/u/nanaki658)\
**Post date:** [February 23, 2023, 8:01pm UTC](https://community.auth0.com/t/need-to-call-discord-api-with-auth-token-to-retrieve-additional-info/101180/1 "2023-02-23T20:01:05Z")

</div>

Im trying to figure out the best way to retrieve additional information from discord during the login flow. Im using an application instead of an API so as far as I can tell there is no way to make the discord API calls from inside the app (angular front end) with the valid user token.  
So far I can successfully log in to my app using a discord sign-on.  
Would the best approach be to use an action? I haven’t found any examples yet of making an API call during the login process. Any help would be appreciated!

---

<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:** [February 25, 2023, 12:47am UTC](https://community.auth0.com/t/need-to-call-discord-api-with-auth-token-to-retrieve-additional-info/101180/3 "2023-02-25T00:47:51Z")

</div>

Hi @nanaki658,

Thanks for reaching out to the Auth0 Community!

To make Discord API calls during the login flow, I recommend checking out the instructions in our [How do I make an Axios API call and store it as a custom claim using Actions?](https://community.auth0.com/t/how-do-i-make-an-axios-api-call-and-store-it-as-a-custom-claim-using-actions/84491) FAQ on using an Action to call an API.

Please let me know if you have any questions about the implementation.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![nanaki658](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nanaki658/32/39337_2.png) [@nanaki658](https://community.auth0.com/u/nanaki658)\
**Post date:** [March 6, 2023, 4:04pm UTC](https://community.auth0.com/t/need-to-call-discord-api-with-auth-token-to-retrieve-additional-info/101180/4 "2023-03-06T16:04:04Z")

</div>

Thank you for the response! Sadly this is not quite what I was looking for as I need the access token created by the login (in this case Discord) to use in the the header as Header: Bearer + accessToken.

Is there no way to access the token at this stage? My ultimate goal is to retrieve a little more user data to include as metaData before sending it along to the calling site. The extra data that is required is included in the “scopes” so the user is aware of having this data gathered.

---

<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:** [March 6, 2023, 9:36pm UTC](https://community.auth0.com/t/need-to-call-discord-api-with-auth-token-to-retrieve-additional-info/101180/5 "2023-03-06T21:36:53Z")

</div>

Hi @nanaki658,

Thank you for your response and clarification.

> [@nanaki658](#):
>
> Is there no way to access the token at this stage?

Unfortunately, it is not possible with a Post-Login Action because they execute before issuing an access token. See the flow diagram below:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/3/d/3d9b9e3a6d074bd17799f5c0765ebce86b4a4e8b.png)

> [@nanaki658](#):
>
> My ultimate goal is to retrieve a little more user data to include as metaData before sending it along to the calling site.

One possible way to get this to work is by making a request with the Discord API using the [Client Credentials grant](https://discord.com/developers/docs/topics/oauth2#client-credentials-grant) inside a Post-Login Action to get a Discord API access token, which you can use to query the Discord API’s [Get User endpoint](https://discord.com/developers/docs/resources/user#get-user).

Then you can take the user\_metadata from the Discord response and append it as a custom claim to the access token.

I hope the explanation was clear!

Please let me know how this works for you.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![nanaki658](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nanaki658/32/39337_2.png) [@nanaki658](https://community.auth0.com/u/nanaki658)\
**Post date:** [March 7, 2023, 2:30pm UTC](https://community.auth0.com/t/need-to-call-discord-api-with-auth-token-to-retrieve-additional-info/101180/6 "2023-03-07T14:30:35Z")

</div>

I actually found a way to accomplish what I needed via RULES. I made the API call with AXIOS and added the Bearer + Token which was available in the user object to retrieve the data I needed before setting it as the app\_metadata.  
Is there a functional difference between app\_metadata and user\_metadata properties? Is there any reason I SHOULDN’T be using a rule for this functionality?

---

<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:** [March 7, 2023, 7:19pm UTC](https://community.auth0.com/t/need-to-call-discord-api-with-auth-token-to-retrieve-additional-info/101180/7 "2023-03-07T19:19:42Z")

</div>

Hi @nanaki658,

Thank you for your reply, and I am glad you got it working using Rules.

> [@nanaki658](#):
>
> Is there a functional difference between app\_metadata and user\_metadata properties?

There is no functional difference between app\_metadata and user\_metadata properties, only a semantic difference.

The difference between `app_metadata` and `user_metadata` is that the first should be used for information about the user that is **controlled by the application** (e.g. the user identifier for a legacy system, or the roles a user has), whereas `user_metadata` is information that the user can view and control (e.g. user settings, preferences). [Reference: [Differences between client\_metadata and app\_metadata](https://community.auth0.com/t/differences-between-client-metadata-and-app-metadata/21388#:~:text=The%20different%20between,user%20settings%2C%20preferences)).]

> [@nanaki658](#):
>
> Is there any reason I SHOULDN’T be using a rule for this functionality?

You should be completely fine with using a Rule for this functionality but, take note that Rules may be deprecated eventually. Because of this, I recommend reading this [related community post](https://community.auth0.com/t/is-there-any-timeline-on-rules-deprecation/99004/2) that answers questions on the timeline on deprecating Rules.

May I help you with anything else?

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![nanaki658](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nanaki658/32/39337_2.png) [@nanaki658](https://community.auth0.com/u/nanaki658)\
**Post date:** [March 7, 2023, 10:51pm UTC](https://community.auth0.com/t/need-to-call-discord-api-with-auth-token-to-retrieve-additional-info/101180/8 "2023-03-07T22:51:01Z")

</div>

nope, that’s everything I needed. Thanks for the help!

---

<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:** [March 21, 2023, 10:51pm UTC](https://community.auth0.com/t/need-to-call-discord-api-with-auth-token-to-retrieve-additional-info/101180/9 "2023-03-21T22:51:57Z")

</div>

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