Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set a custom token for a jupyter notebook?

I have tried putting c.NotebookApp.token = 'test' but that doesn't work and instead treats it like an empty string so the notebook requires no auth.

like image 848
user3792170 Avatar asked Nov 26 '17 01:11

user3792170


People also ask

How do I find my jupyter notebook password or token?

Where is the password for jupyter notebook? If you forget your password and need to reset it: Open your Jupyter environment. Then run "jupyter notebook password". Enter a new password when prompted.

What is a Jupyter token?

When token authentication is enabled, the notebook uses a token to authenticate requests. This token can be provided to login to the notebook server in three ways: in the Authorization header, e.g.: Authorization: token abcdef...


2 Answers

jupyter notebook --NotebookApp.token=abcd

note: ABCD doesn't seem to work. I think it must be lowercase hexadecimal

like image 79
wotanii Avatar answered Sep 17 '22 12:09

wotanii


Maybe a bit late, but hopefully still helpful.

If you want to put a string you can use the c.NotebookApp.password field instead. This way you can set an arbitrary password to access your notebook.

Though, ideally you should hash the password first so it is not discoverable in the config file (or script if you are using command line arguments).

You can hash a password within Python using:

from notebook.auth import passwd
passwd()

This will ask you for a password in the prompt and output a hashed password that you can later set in the config file:

c.NotebookApp.password = u'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'

From the Jupyter documentation

like image 35
Jorge Martínez Avatar answered Sep 18 '22 12:09

Jorge Martínez