Using @discordjs/rest to make requests using Bearer access token
Is it possible to use the rest functions to fetch data for users with their OAuth access_token?
Currently I've tried the following, the only option I got working was with a self made API call, I was wondering if I could utilize the REST class instead.
DISCORD_CLIENT_TOKEN
is the token for my bot/application
accessToken
is the bearer token for the user
4 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OPNode Version:
v18.17.1
how would I go about making the requests use the users bearer token with that?
I can't find a way to configure it to do that, this results in a 401 as well
Try removing the headers option and use
authPrefix: 'Bearer'
instead.oh perfect, thank you! this works now 😄