Access the Jupyter Notebook by passing the credentials in URL

If you manage the notebook server, I think you can define the token when you start the server and open a notebook directly by passing in the token:

jupyter notebook --NotebookApp.tokenUnicode ="mytoken"

If you set it to ‘’ then authentication is disabled.

(NB the current docs seem to specify NotebookApp.tokenUnicode but I’m sure I’ve always used NotebookApp.token in the past. I don’t know if there is a change note about this somewhere, or whether NotebookApp.token now breaks. If so, I may have some nightmare maintenance to do…!)

You can then launch with:

open "http://localhost:8888?token=mytoken".

If you are using docker to run notebooks via the official Jupyter containers, you can pass in a token when you run the container:

docker run --rm -d --name democontainer -p 9999:8888 -e JUPYTER_TOKEN="mytoken" jupyter/base-notebook

Or define an environment variable:
export JUPYTER_TOKEN='mytoken'

and then run:

docker run --rm -d --name democontainer -p 9999:8888 -e JUPYTER_TOKEN jupyter/base-notebook

and open with:

open "http://localhost:9999?token=${JUPYTER_TOKEN}"

Alternatively, you can set c.NotebookApp.tokenUnicode in the ~/.jupyterjupyter_notebook_config.py file as required (see the docs.

1 Like