The is a simple example of a web app querying the Azure Resource Graph API and asking information about the authenticated user. The sript allow you either to pick the user uset previously from a persistent cache or initae a new login.
pyenv local 3.10.13 python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt pip install --upgrade pip
The code from this repository uses an instance of the PublicClientApplication class and performs authentication and authorization functions in Single Page Applications to obtain JWT tokens.
Public applications are essentially applications that run on devices or desktop machines, or even a single page web application.
They do not require Redirect URI or in other words a web address that the user's browser is sent to after they have authenticated with an identity provider.
Let the application fetch information about the logged user from Microsoft Graph, in particular grant permission for User.Read
Create a copy of the .env-template file with the name of .env and fill in values of the variables from App registration > Manage > Certificates & secrets
cp .env-template .env

