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

Viewed 6704

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.

2 Answers
jupyter notebook --NotebookApp.token=abcd

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

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

Related