{"library":"streamlit-authenticator","title":"Streamlit Authenticator","type":"library","description":"Streamlit Authenticator (current version 0.4.2) is a Python library that provides a secure authentication module to manage user access in Streamlit applications. It offers various widgets for login, logout, user registration, password reset, and user detail modification, supporting both local credential management and integration with OAuth2 providers. The library is actively maintained with frequent releases introducing new features and improvements.","language":"python","status":"active","last_verified":"Mon May 18","install":{"commands":["pip install streamlit-authenticator"],"cli":null},"imports":["import streamlit_authenticator as stauth\nauthenticator = stauth.Authenticate(...)","import streamlit_authenticator as stauth\nhashed_passwords = stauth.Hasher(passwords).generate()"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/mkhorasani/Streamlit-Authenticator","docs":null,"changelog":null,"pypi":"https://pypi.org/project/streamlit-authenticator/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import streamlit as st\nimport streamlit_authenticator as stauth\nimport yaml\nfrom yaml.loader import SafeLoader\n\n# --- User Credentials & Cookie Configuration (typically from config.yaml) ---\nconfig = {\n    'credentials': {\n        'usernames': {\n            'john_doe': {\n                'email': 'john@example.com',\n                'name': 'John Doe',\n                'password': 'abc' # Will be hashed if auto_hash is True\n            },\n            'rebecca_smith': {\n                'email': 'rebecca@example.com',\n                'name': 'Rebecca Smith',\n                'password': 'def'\n            }\n        }\n    },\n    'cookie': {\n        'expiry_days': 30,\n        'key': 'random_signature_key_here',\n        'name': 'my_app_cookie'\n    }\n}\n\n# To simulate loading from file (for demonstration, usually you'd load from actual config.yaml)\n# In a real app, you would load this from a persistent config.yaml file.\n# Example: with open('config.yaml') as file:\n#              config = yaml.load(file, Loader=SafeLoader)\n\n# Hash passwords only if not already hashed (auto_hash=True by default in Authenticate)\n# You can pre-hash them explicitly if you wish:\n# for username, user_data in config['credentials']['usernames'].items():\n#    user_data['password'] = stauth.Hasher([user_data['password']]).generate()[0]\n\n# --- Initialize Authenticator ---\nauthenticator = stauth.Authenticate(\n    config['credentials'],\n    config['cookie']['name'],\n    config['cookie']['key'],\n    config['cookie']['expiry_days'],\n    # api_key=os.environ.get('STREAMLIT_AUTH_API_KEY', None) # For 2FA/email features\n)\n\n# --- Login Widget ---\nname, authentication_status, username = authenticator.login('Login', 'main')\n\nif authentication_status == False:\n    st.error('Username/password is incorrect')\nelif authentication_status == None:\n    st.warning('Please enter your username and password')\nelif authentication_status:\n    # --- Main App Content for Authenticated Users ---\n    authenticator.logout('Logout', 'main')\n    st.write(f'Welcome *{name}*')\n    st.title('Application Content')\n    st.write('This content is only visible to authenticated users.')\n\n    # Example of accessing user info from session state\n    # st.write(f\"Current user: {st.session_state['username']}\")\n    # st.write(f\"Authentication status: {st.session_state['authentication_status']}\")\n","lang":"python","description":"This quickstart demonstrates how to set up basic username/password authentication using `streamlit-authenticator`. It initializes the authenticator with credentials (hardcoded for brevity, but typically loaded from a `config.yaml` file), displays a login widget, and then shows protected content upon successful authentication. It also includes a logout button. For a real application, replace hardcoded `config` with loading from a `config.yaml` and consider storing sensitive keys in environment variables.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-18","installed_version":"0.4.2","pypi_latest":"0.4.2","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":17.2,"avg_import_s":2.29,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"streamlit-authenticator","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":2.29,"mem_mb":32.3,"disk_size":"475.3M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"streamlit-authenticator","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":18.3,"import_time_s":1.29,"mem_mb":27.6,"disk_size":"445M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"streamlit-authenticator","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":3.14,"mem_mb":34.9,"disk_size":"496.8M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"streamlit-authenticator","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":16.9,"import_time_s":2.09,"mem_mb":30.3,"disk_size":"466M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"streamlit-authenticator","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":2.97,"mem_mb":34.4,"disk_size":"480.5M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"streamlit-authenticator","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":15.5,"import_time_s":2.27,"mem_mb":29.9,"disk_size":"449M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"streamlit-authenticator","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":2.82,"mem_mb":34.9,"disk_size":"479.2M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"streamlit-authenticator","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":16.1,"import_time_s":2.27,"mem_mb":30.3,"disk_size":"448M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"streamlit-authenticator","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":2.35,"mem_mb":28.5,"disk_size":"460.7M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"streamlit-authenticator","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":19.4,"import_time_s":1.43,"mem_mb":23.7,"disk_size":"439M"}]}}