I had the same problem and just figured out the solution!
Once you successfully receive the access token, you will need to perform an http request to the following endpoint:
https://discordapp.com/api/users/@me
with the headers set to:
Authorization: Bearer ${ACCESS_TOKEN}
You should then receive the following response:
data: {
avatar: ....,
discrimnator: ....,
email: ....,
flags: ....,
id: ....
}
You'll also get some other data points. But those are the big ones. Note: You will only receive the email field if you included that in scope when you received your access token. You can use the id received from this call to hit the users/:userId endpoint referenced in Discord's documentation.
Here is my actual code in case you're interested:
fetchUser: (data) =>
axios
.get(
`https://discordapp.com/api/users/@me`,
{headers: {Authorization: `Bearer ${data.access_token}`}}
)
Hope that helps!