Where to get your Discord bot token and how to keep it safe
Updated · VaultCord
A bot token is the password of your bot. Whatever program holds it can log in as your bot and do anything the bot's roles allow in every server it is in. Discord's own docs put it bluntly: never share your token or check it into any kind of version control.
Where to get it
- 1Open
discord.com/developers/applicationsand pick your application, or click New Application if you do not have one. - 2Go to the Bot page in the left menu.
- 3Under Token, click Reset Token and confirm. Discord may ask for your two-factor code.
- 4Copy the token right away and put it where it will be used, or in a password manager.
You only see a token once. After you leave the page, Discord will not show it again. That is on purpose. Lost it? Reset it and use the new one.
Token, client ID, secret: which is which
The Developer Portal shows several values. Only two of them are secret.
| Value | Where it is | Secret? | What it is for |
|---|---|---|---|
| Application ID (client ID) | General Information, OAuth2 | No | Identifies your app. Goes in invite links. |
| Public key | General Information | No | Lets an app check that interactions really come from Discord. |
| Client secret | OAuth2 | Yes | Lets a website sign members in with Discord for your app. |
| Bot token | Bot | Yes | Logs the bot in. Full control of the bot. |
Resetting it
Clicking Reset Token creates a new token and kills the old one at the same moment. Anything running with the old token is disconnected, and when it tries to log in again Discord rejects it with Gateway close code 4004, authentication failed. That is why a bot often goes offline right after someone "just looked at the token". Plan the reset: have the new token ready to paste into your host or service, then restart the bot.
If your token leaked
It happens: a token pushed to a public repo, pasted in a help channel, or shown in a screen share. Move fast.
- 1Reset the token on the Bot page. This alone stops whoever has the old one.
- 2Paste the new token where your bot runs and restart it.
- 3Check the audit log of every server the bot is in for bans, kicks, deleted channels or role changes made by the bot.
- 4Remove the old token from wherever it leaked. Deleting a file is not enough if it is still in your git history.
- 5Ask how it leaked. If you never shared it, scan your computer. Info-stealing malware takes tokens, passwords and browser sessions.
- 6Rotate the client secret too if it sat in the same file.
Keeping it safe
- Keep it in an environment variable or a
.envfile, and add that file to.gitignorebefore your first commit. - Never put it in a screenshot or a video. Blur the Bot page if you record a tutorial.
- Do not paste it into a website, form or DM unless that service is going to run your bot. A "bot checker" that wants your token can take your bot.
- Give the bot only the permissions it needs. A leaked token for a bot without Ban Members cannot ban anyone.
- Keep two-factor authentication on the Discord account that owns the application.
Bot tokens are not account tokens
A bot token belongs to a bot application. Your own Discord account also has a token in the background, but using your account token to automate your account (a self-bot) breaks Discord's rules and can get the account banned. If you want automation, create a bot. If you want a bot without writing any code, read how to make a Discord bot without coding.
Questions
Where do I find my Discord bot token?
In the Developer Portal, open your application, go to the Bot page and click Reset Token under Token. Discord shows the new token once. Copy it straight away.
Why can't I see or copy my bot token anymore?
Discord only shows a token when it is created. After you leave the page you cannot view it again. If you lost it, reset it and use the new one.
What happens when I reset my bot token?
The old token stops working. Anything still using it gets disconnected and cannot log in again (Gateway close code 4004) until you give it the new token.
Is a bot token the same as the client secret?
No. The bot token logs the bot in. The client secret, on the OAuth2 page, is what a website uses to sign members in with Discord. Both are secrets, and services like VaultCord ask for both.
Is it safe to give my bot token to a bot host?
Only to a service you trust to run the bot, because the token gives full control of the bot. Never paste it into a site, form or chat that does not need to run your bot.