Streamlit auth library based on MSAL.JS
Project description
Streamlit - Microsoft MSAL Authentication
This project is a fork of Ploomber's msal-streamlit-authentication
A Streamlit component for Microsoft Authentication Library (MSAL) integration
pip install msal-streamlit-auth
Overview
This Streamlit component enables seamless client-side authentication using:
- Azure Active Directory (AAD) work and school accounts
- Microsoft personal accounts (MSA)
- Social identity providers (Facebook, Google, LinkedIn, etc.) through Azure AD B2C
Built on the Microsoft MSAL JS Library, it supports any provider using OpenID Connect Authorization Code Flow (PKCE).
Quick Start
-
Register Your Application
- Register a Single Page Application in Azure AD
- Note your Client ID and configure redirect URIs for targeted final URI
-
Install the Package
pip install msal-streamlit-authentication
-
Implementation Example
value = msal_authentication( auth={ "clientId": "YOUR_CLIENT_ID", "authority": "https://login.microsoftonline.com/YOUR_TENANT_ID", "postLogoutRedirectUri": "/" }, cache={ "cacheLocation": "sessionStorage", "storeAuthStateInCookie": False }, login_request={ "scopes": ["YOUR_SCOPE/.default"] } )
Configuration Guide
Required Configuration
-
Client ID: Found in Azure Portal under "Application (client) ID"
📷 Where to find Client ID
-
Tenant ID: Found in Azure Portal under "Directory (tenant) ID"
📷 Where to find Tenant ID
Optional Parameters
msal_authentication(
# ... required config ...
login_button_text="Login", # Default: "Login"
logout_button_text="Logout", # Default: "Logout"
class_name="css_button_class", # CSS class selector
html_id="button_id", # HTML ID
key="1" # Streamlit component key
)
Scopes Configuration
For more information on configuring scopes and permissions, see the official documentation.
Basic scope example:
login_request={
"scopes": ["https://graph.microsoft.com/.default"]
}
Redirect URI
By default, MSAL uses the current page as the redirect URI. To customize:
auth={
# ... other config ...
"redirectUri": "/custom-path",
}
⚠️ All redirect URIs must be registered in your Azure portal application settings.
Additional Resources
Acknowledgments
Built with inspiration from:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file msal_streamlit_auth-1.1.3.tar.gz.
File metadata
- Download URL: msal_streamlit_auth-1.1.3.tar.gz
- Upload date:
- Size: 157.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59e7f1381939f3c6706fe3cfa4128bfe69297115ab50bc2ed5485e423733e5ab
|
|
| MD5 |
574afbbec7871303fd5f5888894d1897
|
|
| BLAKE2b-256 |
2f45ad7790f189efa1c449b7fa83fdeff599a71e283db08ef5a4e6b4e1a2729e
|
File details
Details for the file msal_streamlit_auth-1.1.3-py3-none-any.whl.
File metadata
- Download URL: msal_streamlit_auth-1.1.3-py3-none-any.whl
- Upload date:
- Size: 157.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64159ea2b0c927c91462e5271c03ebfb698774abc1e9f6f0a0d4fa93f1e154a9
|
|
| MD5 |
81739ecc3abe495a8bf8a15ffe566e8b
|
|
| BLAKE2b-256 |
9e4b253e6c535d90f7846c54ed071f6ea50438871aac58d4aaf5a2febc3137a6
|