My streamlit Version: 1.41.1 & streamlit-authenticator Version: 0.4.1
Code:
import streamlit as st
import yaml
import streamlit_authenticator as stauth
from yaml.loader import SafeLoader
import bcrypt
Load configuration
try:
with open(‘config.yaml’) as file:
config = yaml.load(file, Loader=SafeLoader)
st.write(“Configuration loaded:”, config)
except Exception as e:
st.error(f"Error loading configuration: {e}")
st.stop()
Initialize authenticator
try:
authenticator = stauth.Authenticate(
config[‘credentials’],
config[‘cookie’][‘name’],
config[‘cookie’][‘key’],
config[‘cookie’][‘expiry_days’]
)
st.write(“Authenticator initialized.”)
except Exception as e:
st.error(f"Error initializing authenticator: {e}")
st.stop()
Display login form
try:
result = authenticator.login(key=‘Login’, location=‘main’)
st.write(“Login result:”, result)
if result is None:
st.error(“Login form did not render correctly. Check your configuration.”)
else:
name, authentication_status, username = result
st.write(f"Login result: {authentication_status}, Username: {username}“)
except Exception as e:
st.error(f"An error occurred: {e}”)
Why I am getting following error:
Login result: None
Login form did not render correctly. Check your configuration.