mkhorasani / Streamlit-Authenticator

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

Your app is having trouble loading the extra_streamlit_components.CookieManager.cookie_manager component. #69

Closed ihpolash closed 10 months ago

ihpolash commented 1 year ago

I'm trying to implement login option on my app. But getting this error & can't login to the main body.

Please help.



(The app is attempting to load the component from ****, and hasn't received its "streamlit
" message.)

If this is a development build, have you started the dev server?
If this is a release build, have you compiled the frontend?
For more troubleshooting help, please see the [Streamlit Component docs](https://docs.streamlit.io/library/components) or visit our [forums](https://discuss.streamlit.io/).```
mkhorasani commented 1 year ago

Hi @ihpolash can you please share your code?

ihpolash commented 1 year ago

@mkhorasani Here is the code. I've implemented under pages/train.py

import streamlit as st
import streamlit_authenticator as stauth

import yaml
from yaml.loader import SafeLoader

# hashed_passwords = stauth.Hasher(['abc']).generate()
st.set_page_config(initial_sidebar_state="collapsed")

with open('config.yaml') as file:
    config = yaml.load(file, Loader=SafeLoader)

st.markdown(
    """
<style>
    [data-testid="collapsedControl"] {
        display: none
    }
</style>
""",
    unsafe_allow_html=True,
)

hide_menu = """
<style>
#MainMenu {
    visibility:hidden;
}

footer{
    visibility:hidden;
}

</style>
"""

def main():

    authenticator = stauth.Authenticate(
          config['credentials'],
          config['cookie']['name'],
          config['cookie']['key'],
          config['cookie']['expiry_days'],
          config['preauthorized']
      )

    name, authentication_status, username = authenticator.login('Login', 'main')

    st.markdown(hide_menu, unsafe_allow_html=True)
    if authentication_status:
        authenticator.logout('Logout', 'main', key='unique_key')
        # st.markdown('<h1 style="color:black;">Model Training</h1>', unsafe_allow_html=True)
        # st.markdown('<h2 style="color:gray;">Upload dataset</h2>', unsafe_allow_html=True)
        # set_png_as_page_bg('bg.jpg')

        upload= st.file_uploader('Insert zip file for training', type=['zip'])

        extract_dir = 'data'
        if upload is not None:
            # Unzip the file
            unzip_file(upload, extract_dir)

            hist = train_test_data_gen()

            fig, ax = plt.subplots()
            ax.plot(hist.history['accuracy'])
            ax.plot(hist.history['val_accuracy'])
            ax.set_title('model accuracy')
            ax.set_ylabel('accuracy')
            ax.set_xlabel('epoch')
            # ax.set_legend(['train', 'val'], loc='upper left')
            st.pyplot(fig)
            K.clear_session()

    elif authentication_status is False:
        st.error('Username/password is incorrect')
    # elif authentication_status is None:
    #     st.warning('Please enter your username and password')

if __name__ == "__main__":
    main()
ibehnam commented 11 months ago

any follow up on this? I think the cookie manager is not updated to account for some deprecations in Streamlit cache system.

borisko123 commented 10 months ago

the same for me

ibehnam commented 10 months ago

any update from the developer?

mkhorasani commented 10 months ago

Dear all I have made the following PR to the developer to update the library. Please stay tuned.

sostholm commented 10 months ago

I'm still having this issue with streamlit-authenticator==0.2.2