Replit "secrets" isn't working

Description:
I have a discord bot that does nothing (just the “set up” code), made with discord.py.
When I pass the token directly as a variable, it runs normally.
But I don’t want the token to be exposed, so I copy it into “secrets”.
When I run it again, it says the “token is improper”, while the same token works when passed directly.
I have tried to reset the token, repl, browser etc. I’ve tried making a new repl and using a new bot, but it still doesn’t work.
I have other bots/repls that work normally with their token in “secrets” (that were made before this bug appeared).

Here is the repl where the problem appears:
https://replit.com/@leo26k/testbot#main.py

Error:
raise HTTPException(response, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized

raise LoginFailure(‘Improper token has been passed.’) from exc
discord.errors.LoginFailure: Improper token has been passed.

I recently ran into a similar problem. I had an error due to the fact that the secret key had the characters < and >.

Your error may occur due to the presence of specific characters in the secret key, or due to an incorrectly entered secret key.

2 Likes

You are right, it turns out the string quotes caused the error, although I’m pretty sure that wasn’t the issue in other occasions.
Thank you for your tree reply.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.