page_type | languages | products | description | urlFragment | ||
---|---|---|---|---|---|---|
sample |
|
|
This sample demonstrates a Python web application calling a Microsoft Graph that is secured using Azure Active Directory. |
ms-identity-python-webapp |
Integrating Microsoft Identity Platform with a Python web application
This is a Python web application that uses the Flask framework and the Microsoft identity platform to sign in users and make authenticated calls to the Microsoft Graph API.
To get started with this sample, you have two options:
- Use the Azure portal to create the Azure AD applications and related objects. Follow the steps in Quickstart: Add sign-in with Microsoft to a Python web app.
- Use PowerShell scripts that automatically create the Azure AD applications and related objects (passwords, permissions, dependencies) for you, and then modify the configuration files. Follow the steps in the App Creation Scripts README.
Deployment
Once you finish testing this web app locally, you can deploy it to your production. You may choose any web app hosting services you want. Here we will describe how to deploy it to Azure App Service.
-
Follow the "Quickstart: Deploy a Python (Django or Flask) web app to Azure App Service", but replace its sample app (which does not do user sign-in) with this web app.
-
In particular, if you choose to "deploy using Local Git" in "step 3 - Deploy your application code to Azure", an application-scope credential will be automatically created with the shape as
your_app_name\$your_app_name
. But your actual git username is only the$your_app_name
part. -
Configure your app's settings to define these environment variables.
Contributing
If you find a bug in the sample, please raise the issue on GitHub Issues.
If you'd like to contribute to this sample, see CONTRIBUTING.MD.
This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.