Is it necessary to store the personal access token somewhere locally on the machine after generating it in GitHub?
If yes, is there any preferred way where it could be
I like to keep them encrypted within the repository and load them using .envrc
(https://direnv.net/)
For doing this I use ssh-vault to encrypt the data using my ssh keys that GitHub already is exposing, for example:
echo MY_TOKEN="secret" | ssh-vault -u create > my-encypted-vars.ssh
Then the content of .envrc
looks something like this:
echo "Enter ssh key password"
context=$(ssh-vault view $HOME/projects/my-encrypted.ssh | tail -n +2)
export ${context}
This will decrypt the data in my-encrypted-vars.ssh
file and set MY_TOKEN
into my environment variables every time I cd
into the project dir.
By doing this tokens/variables are stored "safely" and always ready to use as environment variables