Hi Bakar
To add authentication to your Streamlit app and enable users to login with their accounts, you can make use of the Azure AD authentication flow. Here are the steps you can follow:
Create an Azure App Registration: In the Azure portal, create an App Registration and configure it as a web application. Obtain the client ID for your app registration.
Choose the appropriate client type: Based on your requirements, decide whether you want to use the PublicClientApplication or ConfidentialClientApplication class for authentication.
PublicClientApplication: This client type is suitable for public client applications, such as single-page web apps or mobile apps. It does not require a client secret and can handle interactive authentication flows.
ConfidentialClientApplication: This client type is intended for confidential client applications, such as web apps with server-side logic. It requires a client secret and can handle both interactive and non-interactive authentication flows.
Implement authentication in your Streamlit app:
a. Import the necessary libraries for Azure AD authentication. For example, you can use the MSAL (Microsoft Authentication Library) library for Python.
b. Configure the client ID and other relevant parameters in your Streamlit app.
c. Use the appropriate class (PublicClientApplication or ConfidentialClientApplication) to initiate the authentication process and handle the authentication flow. For the PublicClientApplication, you can use the acquire_token_interactive
method to trigger the login-popup and authenticate the user.
- Once the user is authenticated, you can access their claims, such as the user name, from the token provided by Azure AD.
**[Azure Active Directory authentication with Streamlit](https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-v2-python-webapp-msal)**
Kindy accept answer if it helps