1

I am installing a package in jupyter notebook but I don't want my token exposed. How can I achieve this? I am using python and jupyter notebook

%pip install git+https://<token>@dev.azure.com/company-projects/company/_git/cpoo
krmogi
  • 2,588
  • 1
  • 10
  • 26
Ash
  • 319
  • 1
  • 11
  • 1
    can you set environment variable on juypter? If so, that's probably what I'd suggest using – rv.kvetch Oct 21 '21 at 22:44
  • 1
    https://stackoverflow.com/questions/14409167/how-to-pass-a-variable-to-magic-%C2%B4run%C2%B4-function-in-ipython This lets you use a variable in a magic command like %pip. You can load the token from whatever you'd like (user input, environment variable, file not checked into VCS etc) – Kaia Oct 21 '21 at 22:48
  • @Kaia thanks, Let me try this :) – Ash Oct 21 '21 at 22:52
  • 1
    pip also support authenticate using a `.netrc` file, without need set the token in the url (https://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-file.html) – Gonzalo Odiard Oct 21 '21 at 23:07
  • Thanks Legends, I was able to solve this using ```import getpass``` and ```password = getpass.getpass()``` So, all good :) – Ash Oct 21 '21 at 23:39

0 Answers0