# Help with authenticator form

**URL:** <https://discuss.streamlit.io/t/help-with-authenticator-form/64157>\
**Category:** Custom Components\
**Tags:** discussion\
**Created:** [March 7, 2024, 8:29pm UTC](https://discuss.streamlit.io/t/help-with-authenticator-form/64157 "2024-03-07T20:29:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexandre\_Choske](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/alexandre_choske/32/33456_2.png) [@Alexandre\_Choske](https://discuss.streamlit.io/u/Alexandre_Choske)\
**Post date:** [March 7, 2024, 8:29pm UTC](https://discuss.streamlit.io/t/help-with-authenticator-form/64157/1 "2024-03-07T20:29:06Z")

</div>

Hi guys, I’m using this library to make an authenticator login system on my web app but also having a hard time to make it work as expected in layouts.

The library is **import streamlit\_authenticator as stauth**.

When I use it inside a container, my form is pretty (as it becomes smaller). But the problem is that when I log in, the form is showing above the content of the screen for some seconds until I refresh it.

 ![image](https://global.discourse-cdn.com/streamlit/original/3X/5/2/52169e6520c59749ec826654b28b29cc4b8ee16d.png)

Logged in \/

 ![image](https://global.discourse-cdn.com/streamlit/original/3X/1/a/1aecbff8db99a6436272c09623211369d08a0a82.jpeg)

When I use it alone without the container, it shows a very large form (ugly), but when logged successfully, it is not bugged.

 ![image](https://global.discourse-cdn.com/streamlit/original/3X/8/f/8fa7a7e7770bb20c6a816e23ca6965bf2d4348ba.jpeg)  
 ![image](https://global.discourse-cdn.com/streamlit/original/3X/0/6/06ba352dbc88f9171c2945f28de71ce1a0169e3c.png)

This way when logged in, it is not bugged as above.

Any help would be appreciated 🤔

---

<div class="post-metadata">

**Author:** ![ferdy](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/ferdy/32/29957_2.png) [@ferdy](https://discuss.streamlit.io/u/ferdy)\
**Post date:** [March 7, 2024, 11:59pm UTC](https://discuss.streamlit.io/t/help-with-authenticator-form/64157/2 "2024-03-07T23:59:29Z")

</div>

What version of authenticator do you use?

---

<div class="post-metadata">

**Author:** ![Alexandre\_Choske](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/alexandre_choske/32/33456_2.png) [@Alexandre\_Choske](https://discuss.streamlit.io/u/Alexandre_Choske)\
**Post date:** [March 8, 2024, 12:14am UTC](https://discuss.streamlit.io/t/help-with-authenticator-form/64157/3 "2024-03-08T00:14:04Z")

</div>

Im using this.

streamlit\_authenticator==0.2.3

---

<div class="post-metadata">

**Author:** ![Alexandre\_Choske](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/alexandre_choske/32/33456_2.png) [@Alexandre\_Choske](https://discuss.streamlit.io/u/Alexandre_Choske)\
**Post date:** [March 8, 2024, 12:21am UTC](https://discuss.streamlit.io/t/help-with-authenticator-form/64157/4 "2024-03-08T00:21:37Z")

</div>

For a matter of fact, I tried to update the lib.

But got the same result as well…

![image](https://global.discourse-cdn.com/streamlit/original/3X/2/a/2aa76256931f78d4da70742dfdd26bf2541a2f8d.png)  
is now  
 ![image](https://global.discourse-cdn.com/streamlit/original/3X/a/a/aad8c52294e3ed35bc9d0f260a7dc6e8691b0bbb.png)

and when loging in.

 ![image](https://global.discourse-cdn.com/streamlit/original/3X/f/f/ff429b405007bf4a0bd0dff1e24986b9d796fdf2.jpeg)

😕

---

<div class="post-metadata">

**Author:** ![ferdy](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/ferdy/32/29957_2.png) [@ferdy](https://discuss.streamlit.io/u/ferdy)\
**Post date:** [March 8, 2024, 12:50am UTC](https://discuss.streamlit.io/t/help-with-authenticator-form/64157/5 "2024-03-08T00:50:24Z")

</div>

First you have to call the login.

```auto
spacer_left, form, spacer_right = st.columns([1, 0.8, 1])
with form:
    authenticator.login(location='main')

```

Then check the status.

```auto
if st.session_state["authentication_status"]:

```

If `authentication_status` is True, you can now display the content. Also show the logout button.

```auto
if st.session_state["authentication_status"]:
    with form:
        authenticator.logout()
        st.write(f'Welcome *{st.session_state["name"]}*')

    # Your content will be here.
    my_content()

```

## Sample full code

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

st.set_page_config(layout='wide')

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']
)

spacer_left, form, spacer_right = st.columns([1, 0.8, 1])
with form:
    authenticator.login(location='main')

if st.session_state["authentication_status"]:
    with form:
        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')

```

Reference:  
[streamlit-authenticator](https://github.com/mkhorasani/Streamlit-Authenticator)

---

<div class="post-metadata">

**Author:** ![Alexandre\_Choske](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/alexandre_choske/32/33456_2.png) [@Alexandre\_Choske](https://discuss.streamlit.io/u/Alexandre_Choske)\
**Post date:** [March 8, 2024, 11:49am UTC](https://discuss.streamlit.io/t/help-with-authenticator-form/64157/6 "2024-03-08T11:49:49Z")

</div>

Thanks mate, I could get this working based on your answer.

Thank you so much.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [March 10, 2024, 11:50am UTC](https://discuss.streamlit.io/t/help-with-authenticator-form/64157/7 "2024-03-10T11:50:31Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
