I am working on a Python script that access Github using basic authentication. I want to use OAuth so that user doesn’t have to enter credentials every time he uses the script. Most importantly, user’s password does not get saved in the .bash_history.
This Github API has the code to get token using Basic authentication.
`curl -u $USER_NAME --silent https://api.github.com/authorizations`
User is asked to enter password and gets token in the response.
- Now where do I save this token securely so that next time when the script is run user doesn’t have to enter anything?
- The aim is to avoid storing the password or asking the user to enter every time he uses the script. Is there some other way to achieve these?
You should probably save the token in a config file in the user’s home directory. Preferably, you can restrict permissions on the file to make sure that only that user may access the config file.