# Streamlit authenticator-KeyError

**URL:** <https://discuss.streamlit.io/t/streamlit-authenticator-keyerror/60708>\
**Category:** Using Streamlit\
**Tags:** authentication, session-state\
**Created:** [January 25, 2024, 12:46am UTC](https://discuss.streamlit.io/t/streamlit-authenticator-keyerror/60708 "2024-01-25T00:46:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Taiwo\_Osunrinde](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/taiwo_osunrinde/32/13106_2.png) [@Taiwo\_Osunrinde](https://discuss.streamlit.io/u/Taiwo_Osunrinde)\
**Post date:** [January 25, 2024, 12:46am UTC](https://discuss.streamlit.io/t/streamlit-authenticator-keyerror/60708/1 "2024-01-25T00:46:41Z")

</div>

## 🚨 Before clicking “Create Topic”, please make sure your post includes the following information (otherwise, the post will be locked). 🚨

1. Are you running your app locally or is it deployed?  
The app is run locally

2. Share the Streamlit-latest version and Python version:3.10.

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

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

with open('./login_credentials.yaml', 'w') as file:
    yaml.dump(config, file, default_flow_style=False)

authenticator.login()

if st.session_state['authentication_status'] is False:
    st.error("Username/password is incorrect")

if st.session_state['authentication_status'] is None:
    st.warning("Please enter your username and password")

if st.session_state['authentication_status']:
    # plot function
    # @st.cache_data
    st.write(f'Welcome *{st.session_state["name"]}*')
    authenticator.logout()
    def plot(x,y,z):
      my code continues

```

I am trying to create a login authentication page for a streamlit application using streamlit authenticator, after which the user will be taken to the main app if login is successful but I keep getting this error

 ![error](https://global.discourse-cdn.com/streamlit/original/3X/d/5/d54e2323d3e0dbf38cdca0f3933e29734f2f680e.png)

---

<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:** [January 25, 2024, 7:36am UTC](https://discuss.streamlit.io/t/streamlit-authenticator-keyerror/60708/2 "2024-01-25T07:36:07Z")

</div>

> [@Taiwo\_Osunrinde](#):
>
> ```auto
> with open('./login_credentials.yaml', 'w') as file:
> yaml.dump(config, file, default_flow_style=False)
> 
> ```

Put that code at the bottom of the page.

---

<div class="post-metadata">

**Author:** ![Taiwo\_Osunrinde](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/taiwo_osunrinde/32/13106_2.png) [@Taiwo\_Osunrinde](https://discuss.streamlit.io/u/Taiwo_Osunrinde)\
**Post date:** [January 25, 2024, 3:26pm UTC](https://discuss.streamlit.io/t/streamlit-authenticator-keyerror/60708/3 "2024-01-25T15:26:10Z")

</div>

@ferdy do you mean the bottom after the main application body. Thanks

 ![image](https://global.discourse-cdn.com/streamlit/original/3X/6/2/629928da6a785c6e74bdbaf2e0bc111cd882f426.png)

---

<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:** [January 25, 2024, 7:52pm UTC](https://discuss.streamlit.io/t/streamlit-authenticator-keyerror/60708/4 "2024-01-25T19:52:28Z")

</div>

There is [some progress](https://github.com/mkhorasani/Streamlit-Authenticator/issues/111) on this issue.

We better try the latest version.

---

<div class="post-metadata">

**Author:** ![Taiwo\_Osunrinde](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/taiwo_osunrinde/32/13106_2.png) [@Taiwo\_Osunrinde](https://discuss.streamlit.io/u/Taiwo_Osunrinde)\
**Post date:** [January 27, 2024, 4:44pm UTC](https://discuss.streamlit.io/t/streamlit-authenticator-keyerror/60708/5 "2024-01-27T16:44:16Z")

</div>

okay. Thanks

---

<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:** [July 25, 2024, 4:44pm UTC](https://discuss.streamlit.io/t/streamlit-authenticator-keyerror/60708/6 "2024-07-25T16:44:31Z")

</div>

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