Unable to capture the users running webapp properly
![Anony123](https://us.v-cdn.net/6038231/uploads/Dataiku/nAvatar23.png)
Anony123
Registered Posts: 3 ✭
Hi Team,
I am trying to capture the user who is running the webapp as it is shared environment. sometimes it is capturing correctly and sometimes not. It is just showing the one you who started the webapp and displaying the same for every run even some other user runs it. I want to capture the user who is running the dataiku webapp.
Here is my code:
import dataiku
client= dataiku.api_client()
auth_info= client.get_auth_info()
user= auth_info[‘authIdentifier’]
print(user)
Operating system used: Windows
Operating system used: Windows
Tagged:
Answers
-
Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,211 Dataiker
Hi @Anony123
,
If you have python backend to your webapp you can use the following to obtain the user that currently viewing the webapp. Not the "run as" user.python code: @app.route('/get_current_user') def get_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 JavaScript code: $.getJSON(getWebAppBackendUrl('/get_current_user'), function(data) { console.log('Received data from backend', data) const output = $('<pre />').text('Backend reply: ' + JSON.stringify(data)); $('body').append(output) });