discord.py: discord.errors.LoginFailure: Improper token has been passed
Summary
When i try to run my code it shows discord.errors.LoginFailure: Improper token has been passed
Reproduction Steps
1)install discord.py 2)run code
Minimal Reproducible Code
bot.run("TOKEN")
Expected Results
Run the discord bot normally
Actual Results
Shows error
Traceback (most recent call last):
File "C:\Users\andre\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\http.py", line 299, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "C:\Users\andre\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\http.py", line 253, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File ".\bot.py", line 62, in <module>
bot_async_start()
File ".\bot.py", line 49, in bot_async_start
bot.run("Here there is the token ")
File "C:\Users\andre\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 755, in run
return future.result()
File "C:\Users\andre\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 734, in runner
await self.start(*args, **kwargs)
File "C:\Users\andre\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 697, in start
await self.login(*args)
File "C:\Users\andre\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 544, in login
await self.http.static_login(token.strip())
File "C:\Users\andre\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\http.py", line 303, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
Intents
discord.Intents.default
System Information
- Python v3.8.6-final
- discord.py v1.8.1-final
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.22000
Checklist
- I have searched the open issues for duplicates.
- I have shown the entire traceback, if possible.
- I have removed my token from display, if visible.
Additional Context
The token is correctly copied , is the token not the secret, the token is in a string , I also tried to regenerate token and it didn’t worked
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 16 (6 by maintainers)
I faced same err.
But my discord self bot is working well on Win10, python 3.13 I got discord user token like this.
But on Mac, “Improper token passed”.
What is this? How to fix it?
Using self-bots is against ToS and discord.py has removed all methods and any references to them in v2.
I’m having the same issue while trying to create a self bot (automatizing my main account). How can I fix it?
I suppose it’s because you store token in .env, so it’s cached. All you have to do is reopen your IDE or update .env file with set_key(i didn’t try it, reopening my VSC helped, so i just suppose that it might be helpful too)
I know. But I need to monitor discord account, not bot. Bot cant join all of server I want, I need to monitor servers or channels that my discord account joined. For this, I wanna use discord-self bot. Anyway, I solved this problem using Node.js server. Thank you.