Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-18667 Add support to display_firefly for obtaining and passing along an authorization token for Firefly #30

Merged
merged 2 commits into from
Aug 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion doc/lsst.display.firefly/defining-displays-lsp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ This command is specific to the Firefly backend of the afwDisplay framework.
Defining a Display to open a browser tab
========================================

The first time that a Display object is instantiated in your Python or noteook
The first time that a Display object is instantiated in your Python or notebook
session, you can specify that a browser tab be opened. You will need to allow
pop-ups for the science platform site.

Expand All @@ -84,6 +84,15 @@ Click on the link to bring up a browser tab or window. Your browser or system
settings determine whether the link brings up a tab, or a window.


Authorizing a Display
=====================

When working inside the LSST Science Platform with default settings,
authorization of the connection to the Firefly server will be handled
automatically. If you encounter a need to pass a token for authorization,
you can pass it to the first Display instance you create, with
the ``token=`` keyword parameter.

Embedding the Firefly viewer in a notebook
==========================================

Expand Down
12 changes: 10 additions & 2 deletions python/lsst/display/firefly/firefly.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,27 @@ def __init__(self, display, verbose=False, url=None,
url = os.environ['FIREFLY_URL']
else:
raise RuntimeError('Cannot determine url from environment; you must pass url')

token = kwargs.get('token',
os.environ.get('ACCESS_TOKEN', None))

try:
if start_tab:
if verbose:
print('Starting Jupyterlab client')
_fireflyClient = firefly_client.FireflyClient.make_lab_client(
start_tab=True, start_browser_tab=start_browser_tab,
html_file=kwargs.get('html_file'), verbose=verbose)
html_file=kwargs.get('html_file'), verbose=verbose,
token=token)

else:
if verbose:
print('Starting vanilla client')
_fireflyClient = firefly_client.FireflyClient.make_client(
url=url, html_file=html_file, launch_browser=True,
channel_override=name, verbose=verbose)
channel_override=name, verbose=verbose,
token=token)

except (HandshakeError, gaierror) as e:
raise RuntimeError("Unable to connect to %s: %s" % (url or '', e))

Expand Down