Files
jupyterhub/examples/service-whoami-flask
Matthias Bussonnier 2e872069fb Use $() for command substitution instead of backticks/quotes.
One of the example was using quotes instead of backticks.
Backticks are the "older" way of doing things, which has a number of
disadvantes:

    http://mywiki.wooledge.org/BashFAQ/082

Here I'm more worried about readability as depending on font and "smart"
editor helping on the web, many people may confuse ` with ', it could
end up modifying formatting on makrdown powered website... etc...
2018-10-04 13:44:16 -07:00
..
2016-10-25 13:24:46 +02:00

Authenticating a flask service with JupyterHub

Uses jupyterhub.services.HubAuth to authenticate requests with the Hub in a flask application.

Run

  1. Launch JupyterHub and the whoami service with

     jupyterhub --ip=127.0.0.1
    
  2. Visit http://127.0.0.1:8000/services/whoami/ or http://127.0.0.1:8000/services/whoami-oauth/

After logging in with your local-system credentials, you should see a JSON dump of your user info:

{
 "admin": false,
 "last_activity": "2016-05-27T14:05:18.016372",
 "name": "queequeg",
 "pending": null,
 "server": "/user/queequeg"
}

This relies on the Hub starting the whoami service, via config (see jupyterhub_config.py).

A similar service could be run externally, by setting the JupyterHub service environment variables:

JUPYTERHUB_API_TOKEN
JUPYTERHUB_SERVICE_PREFIX