Error: 401 Unauthorized help me pls!

What gave you such error on your own?

project name= sdfghjki

1 Like

Hey @cross, the error you’re seeing looks to me like it might be returned from something your bot is trying to use snekfetch to retrieve that your bot doesn’t have permissions to download, but I don’t see anything obvious that would be causing that.

What I do see is that you’re setting PORT in your .env file to an address instead of a number. Since Glitch controls what port is open in your project there’s no reason you should have to set that value, and having it sent incorrectly is what’s causing your bot to continue to attempt to start. The first thing I’d probably do would be to remove that line from your .env file completely and seeing how things look after that.

Hey there,

You’re probably not providing the right bot token. This issue is an API-related issue.
When discord.js is trying to do the task, the API request unauthorized the access to the API, since either you’re providing the bot or as copied from the Discord developer reference on status codes,

Code Meaning
401 (UNAUTHORIZED) The Authorization header was missing or invalid

If your code works perfectly fine with your other bot’s token, then the token you’re using for your bot is invalid. The token, remember, is listed under the APP BOT USER section of the application details page, and is not the Client Secret that you can obtain from the top of the page. If you don’t have an APP BOT USER section, you haven’t created a bot user for your application yet, and will need to do so. However, you say you’ve already invited your bot, so this shouldn’t be an issue.

If you’ve tried this already (including generating and fetching a fresh token) and it still doesn’t work, please tell me the name of the library you’re using, and provide snippets of your code if possible.

We did what they said, but I’ve done them before, but it didn’t work out.

Library I use: discord.js

Hey @cross, please provide your project name, so that I can further look into the issue.

Project Name : zealous-house

Unfortunately, I was not able to find the project, probably because it is private. Invite me to the project so I can look into the issue. Username: chroventer