Dynamically launch Jupyter Notebook after logging into JupyterHub

Hi Jupyter community!

Background

My team and I are working on integrating our product with JupyterHub.
I’ve currently set up JupyterHub such that when a user clicks “Run” on a notebook (as shown below), it logs them into JupyterHub with the notebook loaded into a directory.

Integration workflow:

1. User clicks on "Run"

2. User gets logged into JupyterHub with the notebook present in their home directory

(Note: I used post_auth_hook and pre_spawn_hook to make this work. I passed data using auth_state from the authenticator to spawner.)

Problem/Requirement

Is there a way JupyterHub can dynamically redirect to a notebook (or at least a particular directory) when the user logs in? In the example demonstrated above, JupyterHub should be redirected to
https://<domain>/user/sanjay-rohit2/notebooks/02-reuters/02_reuters.ipynb
(or to the directory /user/sanjay-rohit2/notebooks/02-reuters).

My investigation

I have looked through the docs and found that there are relevant configs such as default_url and notebook_dir. However, these configs are set when the JupyterHub server is started, and is the same for every user, which is why we can’t use them for our requirement.

Any help will be greatly appreciated! Thanks!

cc @yuvipanda @choldgraf @betatim

Solved this by passing /user-redirect/notebooks/{folder}/{filename} to the next query param.

1 Like