How To Add User Authentication On Your Streamlit App

Alessandro Lamberti
Artificialis
Published in
3 min readJan 25, 2022

--

Photo by Micah Williams on Unsplash

In the latest years, Streamlit proved to be one of the easiest and most common way to deploy your Data Science and Machine Learning application.

Streamlit turns data scripts into shareable web apps in minutes.
All in Python. All for free. No front‑end experience required.

However, as with every new tool, there’s still a long way, and Streamlit, with all its contributors, is ensuring to keep developing the library.

The ability to establish a secure login and authentication service for its apps, excluding Streamlit Cloud premium services, is a feature that Streamlit currently lacks natively.

With Streamlit-Authenticator you have at your disposal exactly what you need.

Installation and implementation

For the sake of the tutorial, we’ll implement a simple login form, easy to scale up if needed, as I’ll explain at the end.

Let’s first install the package. Go into your terminal, inside your environment and:

pip install streamlit-authenticator

Let’s now implement it in the streamlit app:

import streamlit as st
import streamlit_authenticator as stauth

--

--