Access the Jupyter Notebook by passing the credentials in URL

Hi ,

I am very much new to start work on Jupyter and I am trying to access the Jupyter Notebook with password less feature or to pass the credentials in url of Jupyter so that user will directly redirected to the notebook page instead of first hit the URL and then manually enter the Credentials .

For e.g. I have jupyter notebook available on my machine and currently it is accessible with url

https://localhost:8999

and after hit of URL it landing on to the credential page on which I need to manually enter the required credentials
But what I was trying to hit the URL https://localhost:8999 and it will land to the home screen which containing all the notebooks
What i was trying to do with the help of this link `https://stackoverflow.com/questions/41159797/how-to-disable-password-request-for-a-jupyter-notebook-session

But this not so much helpful because URL is not accessible and it is alywas generating the new token which tedious to manage

Is there any simpler way to make the Jupyter notebook accessible directly without entering any manual credentials

Can someone please help me ??

1 Like

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

I am so thankful for your response.
I have two question :

  • How can generate the tokens and generation of token is one time and i can use the same token multiple times?

  • i have set the custom token and it is saying “No web browser found: could not locate runnable browser.”

I am so so much thankful for this discussion

If you don’t set the token explicitly, and don’t disable it, the token will be valid until you kill the server. If you set the token explictly, the token will be set to whatever you explicitly set it to.

If the open command doesn’t automatically launch the browser, just enter the URL in your browser location bar: http://localhost:8888?token=mytoken

If you want to check the token set for a running notebook server, you can list the running server(s) and associated tokens by running the following command from the command line: jupyter notebook list

ok,i have got the breakthrough to generate the tokens .
I have jupyter in the container and logs of container is :slight_smile:

//spark-master:7077
[I 18:03:58.808 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[I 18:04:00.662 NotebookApp] Serving notebooks from local directory: /home/admin
[I 18:04:00.662 NotebookApp] 0 active kernels
[I 18:04:00.662 NotebookApp] The Jupyter Notebook is running at: https://127.0.0.1:8888/?token=185779e2c2af5e1a4b33380e657e9ada64e45d6c70f05da9
[I 18:04:00.662 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 18:04:00.665 NotebookApp] No web browser found: could not locate runnable browser.
[C 18:04:00.665 NotebookApp]

Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
    https://127.0.0.1:8888/?token=185779e2c2af5e1a4b33380e657e9ada64e45d6c70f05da9

and the port of the container 8888 is mapped to 8997 of the system port and now i am running url https://localhost:8997/?token=185779e2c2af5e1a4b33380e657e9ada64e45d6c70f05da9 in the chrome browser then getting

This site can’t be reached

ERR_CONNECTION_REFUSED

I think this is the last step i need to rectify.Please please help me !!

can anyone please help me ?

Am i doing something wrong or missing something ?

Did you EXPOSE 8888 in the container Dockerfile?

1 Like

Thanks so much.Working fine now !!