Skip to content

Commit

Permalink
Merge pull request #5587 from NemesisFLX/jupyter_token_file
Browse files Browse the repository at this point in the history
Added support for JUPYTER_TOKEN_FILE
  • Loading branch information
kevin-bates authored Jul 23, 2020
2 parents 9d4852d + 4d1bdf8 commit f5d6995
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions notebook/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,9 @@ def _write_cookie_secret_file(self, secret):
token = Unicode('<generated>',
help=_("""Token used for authenticating first-time connections to the server.
The token can be read from the file referenced by JUPYTER_TOKEN_FILE or set directly
with the JUPYTER_TOKEN environment variable.
When no password is enabled,
the default is to generate a new, random token.
Expand All @@ -945,6 +948,10 @@ def _token_default(self):
if os.getenv('JUPYTER_TOKEN'):
self._token_generated = False
return os.getenv('JUPYTER_TOKEN')
if os.getenv('JUPYTER_TOKEN_FILE'):
self._token_generated = False
with io.open(os.getenv('JUPYTER_TOKEN_FILE'), "r") as token_file:
return token_file.read()
if self.password:
# no token if password is enabled
self._token_generated = False
Expand Down

0 comments on commit f5d6995

Please sign in to comment.