I’m trying to use a preset/static token with my jupyter server. I searched around the documentation and StackOverflow and the internet at large and it seems to be that you can use the NotebookApp.token
in the configuration or the JUPYTER_TOKEN
environment variable. But nothing seems to be working for me. I don’t know if I have something set up wrong or if this is an actual bug somewhere in jupyter.
This is what I’ve got installed on a SL7 box (RHEL/CentOS 7):
$ pip list | grep -E '(jupyter)|(notebook)'
jupyter 1.0.0
jupyter-client 7.2.2
jupyter-console 6.4.3
jupyter-core 4.9.2
jupyter-server 1.16.0
jupyterlab 3.3.3
jupyterlab-pygments 0.1.2
jupyterlab-server 2.12.0
jupyterlab-widgets 1.0.2
notebook 6.4.10
notebook-shim 0.1.0
I think these are very recent/latest versions.
I attempted to invoke the server using:
$ env JUPYTER_TOKEN='abcdef' jupyter notebook --no-browser
[I 16:30:03.361 NotebookApp] Loading IPython parallel extension
[I 2022-04-08 16:30:03.767 LabApp] JupyterLab extension loaded from /home/janderson/code/battery_etl/venv/lib/python3.8/site-packages/jupyterlab
[I 2022-04-08 16:30:03.767 LabApp] JupyterLab application directory is /home/janderson/code/battery_etl/venv/share/jupyter/lab
[I 16:30:03.772 NotebookApp] The port 8888 is already in use, trying another port.
[I 16:30:03.773 NotebookApp] Serving notebooks from local directory: /home/janderson/code/battery_etl
[I 16:30:03.773 NotebookApp] Jupyter Notebook 6.4.10 is running at:
[I 16:30:03.773 NotebookApp] http://localhost:8889/?token=...
[I 16:30:03.773 NotebookApp] or http://127.0.0.1:8889/?token=...
[I 16:30:03.773 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
^C[I 16:30:06.803 NotebookApp] interrupted
Serving notebooks from local directory: /home/janderson/code/battery_etl
0 active kernels
Jupyter Notebook 6.4.10 is running at:
http://localhost:8889/?token=...
or http://127.0.0.1:8889/?token=...
Shutdown this notebook server (y/[n])? y
[C 16:30:07.612 NotebookApp] Shutdown confirmed
[I 16:30:07.612 NotebookApp] Shutting down 0 kernels
[I 16:30:07.614 NotebookApp] Shutting down 0 terminals
I expected to not have an empty token but to have abcdef
as the token. I’ve also tried to set the token in the config file and by using --NotebookApp.token 'abcdef'
. All to no avail. If I run without setting the environment variable then things work just fine and it generates a random token.
[I 16:43:51.712 NotebookApp] Loading IPython parallel extension
[I 2022-04-08 16:43:52.142 LabApp] JupyterLab extension loaded from /home/janderson/code/battery_etl/venv/lib/python3.8/site-packages/jupyterlab
[I 2022-04-08 16:43:52.142 LabApp] JupyterLab application directory is /home/janderson/code/battery_etl/venv/share/jupyter/lab
[I 16:43:52.148 NotebookApp] The port 8888 is already in use, trying another port.
[I 16:43:52.149 NotebookApp] Serving notebooks from local directory: /home/janderson/code/battery_etl
[I 16:43:52.149 NotebookApp] Jupyter Notebook 6.4.10 is running at:
[I 16:43:52.149 NotebookApp] http://localhost:8889/?token=ee91c73befb88cdad1d186d18116fd79c5d21f3a56731be7
[I 16:43:52.149 NotebookApp] or http://127.0.0.1:8889/?token=ee91c73befb88cdad1d186d18116fd79c5d21f3a56731be7
[I 16:43:52.149 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 16:43:52.153 NotebookApp]
To access the notebook, open this file in a browser:
file:///home/janderson/.local/share/jupyter/runtime/nbserver-18865-open.html
Or copy and paste one of these URLs:
http://localhost:8889/?token=ee91c73befb88cdad1d186d18116fd79c5d21f3a56731be7
or http://127.0.0.1:8889/?token=ee91c73befb88cdad1d186d18116fd79c5d21f3a56731be7
^C[I 16:43:57.169 NotebookApp] interrupted
Serving notebooks from local directory: /home/janderson/code/battery_etl
0 active kernels
Jupyter Notebook 6.4.10 is running at:
http://localhost:8889/?token=ee91c73befb88cdad1d186d18116fd79c5d21f3a56731be7
or http://127.0.0.1:8889/?token=ee91c73befb88cdad1d186d18116fd79c5d21f3a56731be7
Shutdown this notebook server (y/[n])? y
[C 16:43:59.729 NotebookApp] Shutdown confirmed
[I 16:43:59.730 NotebookApp] Shutting down 0 kernels
[I 16:43:59.731 NotebookApp] Shutting down 0 terminals
I’ve tried copying a token from this output and using it to run a new notebook server, but that has worked the same way as abcdef
.
Any insight into what could be going wrong would be great.
Thanks