mkhorasani / Streamlit-Authenticator

A secure authentication module to validate user credentials in a Streamlit application.
Apache License 2.0
1.37k stars 229 forks source link

missing 1 required positional argument: 'form_name' #146

Closed iliasmachairas closed 3 months ago

iliasmachairas commented 3 months ago

I follow the tutorial at readme file but when I run

streamlit run app.py

I got the following error: login() missing 1 required positional argument: 'form_name'. I have also created config.yaml file based on the example provided.

My entire code is attached below:

import yaml
from yaml.loader import SafeLoader
import streamlit_authenticator as stauth
import streamlit as st

with open('config.yaml') as file:
    config = yaml.load(file, Loader=SafeLoader)
    authenticator = stauth.Authenticate(
        config['credentials'],
        config['cookie']['name'],
        config['cookie']['key'],
        config['cookie']['expiry_days'],
        config['preauthorized']
)

authenticator.login()

if st.session_state["authentication_status"]:
    authenticator.logout()
    st.write(f'Welcome *{st.session_state["name"]}*')
    st.title('Some content')
elif st.session_state["authentication_status"] is False:
    st.error('Username/password is incorrect')
elif st.session_state["authentication_status"] is None:
    st.warning('Please enter your username and password')

'form_name' is related to 'fields' parameter but there is a default value for it based on the documentation. Have I missed anything?

The version of streamlit-authenticator that I use is 0.2.1

mkhorasani commented 3 months ago

Hi @iliasmachairas, I believe you are using an older version of streamlit_authenticator. Please update to v0.3.1.

iliasmachairas commented 3 months ago

You are right! It worked like a charm!