Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

streamlit-calendar not rendering when using streamlit-cognito-auth-v2==1.0.2 and use_cookies=True #43

Open
heeki opened this issue Jan 15, 2025 · 1 comment

Comments

@heeki
Copy link

heeki commented Jan 15, 2025

I enabled auth with Amazon Cognito, which I was able to do simply with streamlit-cognito-auth-v2==1.0.2. I'm able to get the flow to work and the components to render only after I've properly authenticated to my application. However, when I set use_cookies=True so that users don't need to enter the username/password every time, the calendar component stops rendering.

streamlit==1.41.1
streamlit-calendar==1.2.1
streamlit-cognito-auth-v2==1.0.2

Below are relevant code snippets.

@st.fragment
def render_calendar():
    calendar_state = calendar(
        events=events,
        options=calendar_options,
        custom_css=custom_css,
        key="calendar_state"
    )

authenticator = CognitoAuthenticator(userpool_id, client_id, client_secret, use_cookies=True)
is_logged_in = authenticator.login()
if not is_logged_in:
    with st.container(border=True):
        st.write("please login!")
        st.stop()
else:
    # render page
    render_user()
    render_stats()
    render_calendar()

Here is what the calendar section of the page looks like with use_cookies=False (correctly renders).
Screenshot 2025-01-14 at 9 33 33 PM

Here is what it looks like with use_cookies=True (disappears).
Screenshot 2025-01-14 at 9 35 26 PM

I thought maybe session state was getting mangled for the calendar component, so I looped through and deleted all the keys associated with the auth process (after completing auth), as I don't need any of the tokens any longer. However, cleaning up session state still did not allow the calendar component to properly render.

@heeki
Copy link
Author

heeki commented Jan 17, 2025

I ended up re-implementing the CognitoAuthorizer library in my application so that I could pinpoint what exactly was causing the calendar to not render. I found that the calendar would stop rendering specifically when cookies are set. I then swapped out the cookie manager from extra_streamlit_components to streamlit_cookies_controller and was able to render the calendar. So something with what the former library is doing is causing the calendar to not render. I'll post a cross issue with the former library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant