Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to fix Error Code: 500 (AxiosError code 401) #6

Open
natamongkol opened this issue Apr 6, 2023 · 2 comments
Open

how to fix Error Code: 500 (AxiosError code 401) #6

natamongkol opened this issue Apr 6, 2023 · 2 comments

Comments

@natamongkol
Copy link

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

@rdcr0
Copy link
Owner

rdcr0 commented Apr 6, 2023

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.

@TheWuschelGang
Copy link

TheWuschelGang commented Jun 18, 2024

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
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants