knqyf263 / pet

Simple command-line snippet manager
MIT License
4.45k stars 224 forks source link

Unable to set Gist ID and the access token from the Environment Variable #167

Closed hariprasadraja closed 7 months ago

hariprasadraja commented 3 years ago

For security reasons, I don't want to disclose my gist access token and gist id in the config file and saved it as an environment variable.

General settings can read the environment variables but Gist is unable to do the same.

❯ pet sync
Failed to get gist: GET https://api.github.com/gists/$%7BGIST_TOKEN%7D: 401 Bad credentials []
❯ export GIST_TOKEN='abcd'
❯ pet sync
Failed to get gist: GET https://api.github.com/gists/$%7BGIST_TOKEN%7D: 401 Bad credentials []
❯ echo $GIST_TOKEN
abcd
[General]
backend = "gist"
column = 60
editor = "micro -config-dir ${DOTFILES_PATH}/configs/micro"
selectcmd = "fzf"
snippetfile = "${DOTFILES_PATH}/configs/pet/snippet.toml"
sortby = "description"

[Gist]
access_token = "${GIST_TOKEN}"
auto_sync = true
file_name = "pet-snippet.toml"
gist_id = "${GIST_ID}"
public = false
janneliukkonen commented 2 years ago

Leave the access_token and gist_id empty at the configuration file. Use PET_GITHUB_ACCESS_TOKEN env variable as stated in the README https://github.com/knqyf263/pet#gist.

Set the gist_id in the configuration to the one you receive from first sync run.