# Dash App - Get User ID

**URL:** <https://community.plotly.com/t/dash-app-get-user-id/8865>\
**Category:** Dash Python\
**Created:** [March 8, 2018, 10:24pm UTC](https://community.plotly.com/t/dash-app-get-user-id/8865 "2018-03-08T22:24:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dawndawndedawn](https://avatars.discourse-cdn.com/v4/letter/d/fbc32d/32.png) [@dawndawndedawn](https://community.plotly.com/u/dawndawndedawn)\
**Post date:** [March 8, 2018, 10:24pm UTC](https://community.plotly.com/t/dash-app-get-user-id/8865/1 "2018-03-08T22:24:26Z")

</div>

Hello,

Is there a way to fire an event (e.g. pull User ID) whenever a user opens an app?

I know I can get User ID using the following python code, but I am confused about how to tell Dash to run those functions when a user visits my app?

> import getpass  
> getpass.getuser()

I’m planning on using this UserId together with the login time stamp to track usage on my app.

Thanks,  
Dawn

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [March 21, 2018, 1:22pm UTC](https://community.plotly.com/t/dash-app-get-user-id/8865/2 "2018-03-21T13:22:07Z")

</div>

Are you using `dash-auth`? If so, see [Get username for authenticated user with Dash Basic Auth](https://community.plotly.com/t/get-username-for-authenticated-user-with-dash-basic-auth/6450/3)

---

<div class="post-metadata">

**Author:** ![dawndawndedawn](https://avatars.discourse-cdn.com/v4/letter/d/fbc32d/32.png) [@dawndawndedawn](https://community.plotly.com/u/dawndawndedawn)\
**Post date:** [March 26, 2018, 8:41pm UTC](https://community.plotly.com/t/dash-app-get-user-id/8865/3 "2018-03-26T20:41:06Z")

</div>

This worked for me! Thanks Chris 🙂

---

<div class="post-metadata">

**Author:** ![90debasish](https://avatars.discourse-cdn.com/v4/letter/9/dfb087/32.png) [@90debasish](https://community.plotly.com/u/90debasish)\
**Post date:** [January 30, 2019, 7:44am UTC](https://community.plotly.com/t/dash-app-get-user-id/8865/4 "2019-01-30T07:44:46Z")

</div>

Hi Chris I have seen the link that you provided for user authentication. However in my use case i do not want user to enter their credentials every time. I just want to display the user id when he/she access the app. Currently i have tried using the method  
_import getpass_  
_getpass.getuser()_  
However the issue with this is that it displays the admin ID where the app was hosted, when a new user tries to access the app from his browser it still shows the admin ID instead of the user who access the app through his browser.

I would like to know of a way where the app should be able to pull the user id from the browser itself from where the user is accessing the app

---

<div class="post-metadata">

**Author:** ![90debasish](https://avatars.discourse-cdn.com/v4/letter/9/dfb087/32.png) [@90debasish](https://community.plotly.com/u/90debasish)\
**Post date:** [February 1, 2019, 12:52am UTC](https://community.plotly.com/t/dash-app-get-user-id/8865/5 "2019-02-01T00:52:05Z")

</div>

Is there a way to use getpass.getuser() from a callback request so that i can capture the user ID like we have for capturing the IP address when the user uploads any file:

```
@app.callback(
    Output("tabs-content-example", "children"),
    [Input("upload-data", "filename"), Input("upload-data", "contents"),Input('tabs-example', 'value')]
)
def update_output(uploaded_filenames, uploaded_file_contents,tab):
    """Save uploaded files and regenerate the file list."""
    def get_ip(uploaded_filenames):
        print(request.remote_addr)
        return html.Div(request.remote_addr)
    
    if uploaded_filenames is not None and uploaded_file_contents is not None and tab == 'tab-2-example':
        for name, data in zip(uploaded_filenames, uploaded_file_contents):
            save_file(name, data)
        filename=name
        
        children= uploaded_files(filename)
        
        return children,get_ip(uploaded_filenames)
```
