Streamlit-Authenticator, Part 2: Adding advanced features to your authentication component

How to add advanced functionality to your Streamlit app’s authentication component

Posted in Community, February 7 2023

This is Part 2 of the Streamlit Authenticator component two-part series. In Part 1, we covered how to create an authentication component that allows users to log in and gain privileged access to pages within your app.

In this second part, we'll cover the following:

  • How to create a password reset widget
  • How to create a new user registration widget
  • How to create a forgotten password widget
  • How to create a forgotten username widget
  • How to create an updated user details widget

TL;DR? Here's the repo code.

If your user needs to reset their password to a new one, use the reset_password widget to allow the already logged-in user to change their password:

if authentication_status:
        if authenticator.reset_password(username, 'Reset password'):
            st.success('Password modified successfully')
    except Exception as e:

If you want to allow pre-authorized or even non-pre-authorized users to register, use the register_user widget to allow a user to register for your app. If you want the user to be pre-authorized, set the preauthorization argument to True and add their email to the preauthorized list in the configuration file. Once they have registered, their email will automatically be removed from the preauthorized list in the configuration file.

To let any user register, set the preauthorization argument to False:

    if authenticator.register_user('Register user', preauthorization=False):
        st.success('User registered successfully')
except Exception as e:

If you want to allow a user to reset a forgotten password, use the forgot_password widget to allow them to generate a new random password. This new password will be automatically hashed and stored in the configuration file. The widget will also return the user's username, email, and new random password (for you to securely send to the user):

    username_forgot_pw, email_forgot_password, random_password = authenticator.forgot_password('Forgot password')
    if username_forgot_pw:
        st.success('New password sent securely')
        # Random password to be transferred to user securely
    elif username_forgot_pw == False:
        st.error('Username not found')
except Exception as e:

You can also allow users to reset their username with the forgot_username widget, which lets them retrieve their forgotten username. The widget will also return the user's username and email (for you to securely send to them):

    username_forgot_username, email_forgot_username = authenticator.forgot_username('Forgot username')
    if username_forgot_username:
        st.success('Username sent securely')
        # Username to be transferred to user securely
        st.error('Email not found')
except Exception as e:

You can allow your users to update their name and/or email with the update_user_details widget. The widget will automatically save the updated details in both the configuration file and the reauthentication cookie:

if authentication_status:
        if authenticator.update_user_details(username, 'Update user details'):
            st.success('Entries updated successfully')
    except Exception as e:

Wrapping up

And that concludes our review of the Streamlit-Authenticator component! I hope you now feel confident about securely authenticating users to your Streamlit application with advanced functionalities.

In the meantime, feel free to read more about this component in our book Web Application Development with Streamlit. And if you have any questions, please leave them in the comments below or contact me on LinkedIn.

Happy Streamlit-ing! 🎈

This is a companion discussion topic for the original entry at

Hello, where do the users get stored? Can them be stored in a database?


Awsome post. Tjhe authenticator works perfectly on local because of the yaml file. However, could you provide a solution where we have persistent data and we can store the user data in a common database in Firestore?

Currently im trying to integrate the authenticator with Firestore ( , but the fact that the authenticator adresses the local config file is limiting my solution. Can anybody help?

I have the same issue! Please provide a solution.

You could put the YAML file in a secure cloud storage location. I’m using python 3 and AWS S3. If you are using “config” as the variable for the streamlit-authenticator configuration, then here’s a snippet that may help.

import yaml 
yaml_data = yaml.dump(config, default_flow_style=False)
s3 = boto3.client('s3', aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, region_name = region)
s3.put_object(Bucket=user_config_bucket, Key=user_config_key, Body=yaml_data)
1 Like

The following part is missing in the blogpost, so mentioning it here.

Please remember to update the config file after you use this widget.

Updating the configuration file

*Please ensure that the configuration file is resaved anytime the credentials are updated or whenever the reset_password, register_user, forgot_password, or update_user_details widgets are used.

with open('../config.yaml', 'w') as file: 
    yaml.dump(config, file, default_flow_style=False)
1 Like