Open natamongkol opened 1 year ago
Hey nagamongkol, A 401 error indicates invalid authentication credentials. You can try checking the server log for this. This could be due to invalid client (bot) information, such as the client secret.
Hey, you have to change this part:
fetch('https://discord.com/api/oauth2/token', { method: "POST", body: data_1 }).then(response => response.json()).then(data => { axios.get("https://discord.com/api/users/@me", make_config(data.access_token)).then(response => { res.status(200).send(response.data.username); }).catch(err => { console.log(err); res.sendStatus(500); }); });
to:
fetch('https://discord.com/api/oauth2/token', { method: "POST", body: data_1 }).then(response => response.json()).then(data => { axios.get("https://discord.com/api/v10/users/@me", make_config(data.access_token)).then(response => { res.status(200).send(response.data.username); }).catch(err => { console.log(err); res.sendStatus(500); }); });
(The difference is this (+ v10): .../api/users/@me --> .../api/v10/users/@me )
I try to run but error code 500 in console show
AxiosError {message: 'Request failed with status code 401', name: 'AxiosError', code: 'ERR_BAD_REQUEST', config: {…}, request: ClientRequest, …}
how to fix it