Hide Bot Token in GitHub #7806
-
Hi community, Im using github as version control (some people asked my why im uploading my bots code to github) and i need a way to hide my token in my repo. is there any way to do this. ive seen people do things with other files but idk how to make sure that the last line of my bot.py file so it runs. anyway, i just need a way to censor my token in my repo |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 11 replies
-
You can't* preclude a specific line of a specific file from being committed. Store your token in another file or in environment variables or similar. (*you can, but it's stupid) |
Beta Was this translation helpful? Give feedback.
-
Assuming you have a file to store your token in, create another file called .gitignore. Put the name of the file(the file that your token is being stored in) in the .gitignore file. This should block your secret file from being viewed publicly. |
Beta Was this translation helpful? Give feedback.
-
Why don't you make your repository private? That way you can keep your token safe without worrying about someone else finding it. |
Beta Was this translation helpful? Give feedback.
-
Use can use environment variables with Python dotenv to keep the token secret. And in your .gitignore file you would omit it. Read on the PyPi website. |
Beta Was this translation helpful? Give feedback.
-
This was already answered in the help channel at 3:31pm EST today. You can review that here if interested. The help channel is always there for you, feel free to @ me in it anytime - Chai#9762. It's always going to be faster to ask in the help channel than ask in GitHub discussions :) |
Beta Was this translation helpful? Give feedback.
Use can use environment variables with Python dotenv to keep the token secret. And in your .gitignore file you would omit it. Read on the PyPi website.