Thank reaching out to the community.
Microsoft have the Microsoft Authentication Library for Python which allows you to configure your app so your users can authenticate in Azure AD.
Please review the documentations below.
https://learn.microsoft.com/en-us/python/api/overview/azure/active-directory?view=azure-python
https://learn.microsoft.com/en-us/entra/msal/python/
There are several sample apps and tutorials listed in the docs below you can run for testing purposes.
Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.