Streamlit-Authenticator is not working

I’m building a basic streamlit app. In order to validate user credentials, I’m using the authentification module of streamlit. Only one problem, the code does not work !


TypeError: Authenticate.init() got multiple values for argument ‘cookie_expiry_days’


File “C:\Users_M92\Desktop\Coding\Python\Projects\Personal1\venv\lib\site-packages\streamlit\scriptrunner\”, line 557, in _run_script exec(code, module.dict)

File “”, line 23, in
authenticator = stauth.Authenticate(names, usernames, hashed_passwords,

By the way, I used the same code described here in the official documentation :


    import streamlit as st
    import streamlit_authenticator as stauth
    names = ['John Smith', 'Rebecca Briggs']
    usernames = ['jsmith', 'rbriggs']
    passwords = ['123', '456']
    hashed_passwords = stauth.Hasher(passwords).generate()
    authenticator = stauth.Authenticate(names, usernames, hashed_passwords,
        'some_cookie_name', 'some_signature_key', cookie_expiry_days=30)
    name, authentication_status, username = authenticator.login('Login', 'main')
    if authentication_status:
        authenticator.logout('Logout', 'main')
        st.write('Welcome *%s*' % (name))
        st.title('Some content')
    elif authentication_status == False:
        st.error('Username/password is incorrect')
    elif authentication_status == None:
        st.warning('Please enter your username and password')
    if st.session_state['authentication_status']:
        st.write('Welcome *%s*' % (st.session_state['name']))
        st.title('Some content')
    elif st.session_state['authentication_status'] == False:
        st.error('Username/password is incorrect')
    elif st.session_state['authentication_status'] == None:
        st.warning('Please enter your username and password')

When I removed the argument cookie_expiry_days=30, I get this error instead :

TypeError: list indices must be integers or slices, not str

36, in __init__self.credentials[‘usernames’] = {key.lower(): value for
key, value in credentials[‘usernames’].items()}

Do you have any idea why I keep getting these errors ?

Do check the documentation. The component had changed - it now uses a dict as part of the Authenticator.

1 Like