I am trying to use the PyGithub module in python but after a while, OAuth removes the token because it “would allow other people to interact with GitHub on your behalf”. This is very annoying for me because I have to generate a new token every time. Is there any way to disable this?
Are you pushing the token to GitHub in your repository? If you are, it’s being removed as intended:
Tokens published to public repositories will be revoked and that isn’t something you can turn off. To prevent the token from being compromised or revoked, you should be storing it as an environment variable.
Okay, how do I store environment variables? Is that a GitHub thing or something in my code?
That probably depends substantially on what you use the code for - if it’s just on your local machine then you can store your token in an .env file and use .gitignore to make sure it doesn’t get pushed to GitHub.