diff --git a/jupyterhub/singleuser.py b/jupyterhub/singleuser.py index ad70a312..0412694a 100755 --- a/jupyterhub/singleuser.py +++ b/jupyterhub/singleuser.py @@ -228,11 +228,18 @@ class SingleUserNotebookApp(NotebookApp): super(SingleUserNotebookApp, self).start() def init_hub_auth(self): - if not os.environ.get('JPY_API_TOKEN'): - self.exit("JPY_API_TOKEN env is required to run jupyterhub-singleuser. Did you launch it manually?") + api_token = None + if os.getenv('JPY_API_TOKEN'): + # Deprecated env variable (as of 0.7.2) + api_token = os.environ.pop('JPY_API_TOKEN') + if os.getenv('JUPYTERHUB_API_TOKEN'): + api_token = os.environ.pop('JUPYTERHUB_API_TOKEN') + + if not api_token: + self.exit("JUPYTERHUB_API_TOKEN env is required to run jupyterhub-singleuser. Did you launch it manually?") self.hub_auth = HubAuth( parent=self, - api_token=os.environ.pop('JPY_API_TOKEN'), + api_token=api_token, api_url=self.hub_api_url, ) diff --git a/jupyterhub/spawner.py b/jupyterhub/spawner.py index 6dc495e0..d6f07dc6 100644 --- a/jupyterhub/spawner.py +++ b/jupyterhub/spawner.py @@ -190,7 +190,7 @@ class Spawner(LoggingConfigurable): Environment variables that end up in the single-user server's process come from 3 sources: - This `environment` configurable - The JupyterHub process' environment variables that are whitelisted in `env_keep` - - Variables to establish contact between the single-user notebook and the hub (such as JPY_API_TOKEN) + - Variables to establish contact between the single-user notebook and the hub (such as JUPYTERHUB_API_TOKEN) The `enviornment` configurable should be set by JupyterHub administrators to add installation specific environment variables. It is a dict where the key is the name of the environment @@ -414,7 +414,9 @@ class Spawner(LoggingConfigurable): env[key] = value(self) else: env[key] = value - + + env['JUPYTERHUB_API_TOKEN'] = self.api_token + # deprecated (as of 0.7.2), for old versions of singleuser env['JPY_API_TOKEN'] = self.api_token # Put in limit and guarantee info if they exist.