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!
Hi All,
I'm using dataiku version 9.0.7 and have a requirement to print/capture the user who is using/accessing the Dash webapp to apply data security filter. I tried using below code but below code always returns who is initiated the web app but not the user who is using it.
client=dataiku.api_client()
auth_info=client.get_auth_info()
browser_user=auth_info["authIdentifier"]
I also tried using below code but below code is not working for me. Please help me on this.
#new_browser_user=client.get_auth_info_from_browser_headers(headers_dict, with_secrets=False)
Thanks in advance!
Operating system used: Windows
Hi,
Here is a very small example to retrieve the authenticated user :
import logging
from flask import request
from dash.dependencies import Input, Output, State
@app.callback(
Output('my-output', component_property='children'),
[Input('dummy', 'children')]
)
def get_logged_user(_):
request_headers = dict(request.headers)
auth_info_browser = dataiku.api_client().get_auth_info_from_browser_headers(request_headers)
logging.info((auth_info_browser))
return auth_info_browser["authIdentifier"]
app.layout = html.Div(children=[
html.Div(id='my-output'),
html.Div(id="dummy")
])
To be able to retrieve the authenticated user, you need to set up a callback (@app.callback) that reacts to the load. That is why we set a "dummy" input, as this input will never change, and the callback will be executed once. You have to use a callback to access the request object.
You can not use this code (underneath) as it will retrieve the defined user on the settings page
client=dataiku.api_client()
auth_info=client.get_auth_info()
Best,
Florent