Issue
I have built a discord bot and now want to build a website for it. I have managed to setup an implicit grant with discord oauth2, however I don't know how to get any of my scope values (identity, email, guilds, bot). All I have is the access token, the token type, the time it will take to expire, the guild id and the scopes, which are listed in the url. Please help!!!!
Solution
You need to call the GetCurrentUser Api
It is a GET to https://discord.com/api/users/@me
And you have to pass the Authorization header with your token.
EDIT
In javascript this code should do the work:
fetch('https://discord.com/api/users/@me', {
method: 'GET',
headers: {
'Authorization': jwtToken,
}
})
.then(res => res.json())
.then(data => {
console.log(data);
});
Or async version:
async getUserInfo() {
const response = await fetch('https://discord.com/api/users/@me', {
method: 'GET',
headers: {
'Authorization': jwtToken,
}
});
var data = await response.json();
console.log(data);
}
getUserInfo();
Answered By - Antonio Balsamo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.