Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Iโve written a Webapp that is published to a dashboard. Iโd ideally like to be able to keep a log of who runs the web app, and some info about each run. Do you have any ideas how I can do this? I think it is fairly easy in python to get the user name (see below), but Iโm assuming that the user who only has dashboard read permission wonโt have permission to either append rows to a Greenplum table to store my logs in, or write to a file in a Dataiku folder? Any ideas much appreciated.
import dataiku
client = dataiku.api_client()
auth_info = client.get_auth_info()
print("User running this code is %s" % auth_info["authIdentifier"])
Thanks
in Bokeh it's true that it's much harder to get the connected user from their headers. If you're fine with using unsupported internal APIs, you can do
# get the identifier of the webapp instance for bokeh
session_id = curdoc().session_context.id
# import the helper func from dataiku.webapps.run_bokeh import get_session_headers as get_bokeh_session_headers
# grab the http headers at the time of the websocket creation h = get_bokeh_session_headers(session_id)
# get the user from the headers, with the public API auth_info = dataiku.api_client().get_auth_info_from_browser_headers(h)
Hi,
you can use get_auth_info_from_browser_headers() (see this sample ) to know which DSS user is making calls to the webapp. Since this will return the 'effective' user, you can run the webapp with a specific user that has access to greenplum using the 'run as' in the webapp's Settings
Thanks for the input. I'm new to web apps and I'm actually doing a bokeh web app. Seems I don't have access to things like app? do you have any pointers?
Thanks
Hey @Peter_R_Knight since you are new to webapps, I just wanted to recommend this resource from the Dataiku Academy: Web Apps in Dataiku DSS tutorial. I hope this helps!
in Bokeh it's true that it's much harder to get the connected user from their headers. If you're fine with using unsupported internal APIs, you can do
# get the identifier of the webapp instance for bokeh
session_id = curdoc().session_context.id
# import the helper func from dataiku.webapps.run_bokeh import get_session_headers as get_bokeh_session_headers
# grab the http headers at the time of the websocket creation h = get_bokeh_session_headers(session_id)
# get the user from the headers, with the public API auth_info = dataiku.api_client().get_auth_info_from_browser_headers(h)
Many thanks - that seems to be working.