Custom Option Form returns 500 when user is not yet authenticated

Hello folks! I’m following this small guide to render the profile list dynamically based on the user.

The issue I encounter is that the first time the user actually tries to get into Jupyterhub he gets a 500 Internal Server Error.

This seems to be because I still don’t have the auth information from the user and
user_details = auth_state["oauth_user"] fails.

This is solved if the user logouts and logins again. Any thoughts?
Thanks a lot!

Hey folks, managed to create the flow to fix this after investigating the code. The following snippet after awaiting for the auth state works:

          if not auth_state:
            spawner.handler.clear_login_cookie()
            spawner.handler.redirect(spawner.handler.settings["login_url"])
1 Like