I am trying to connect to azure in the same spirt that I am doing on Windows PowerShell.
Command:
Connect-AzureAD -TenantId "xxxxxxxx-59ed-466e-8759-03044xxx46197" -AccountId "xxxxxxxx-8d16-474a-a795-ddef8ea410e3" -AadAccessToken "xxxxxxxxxx-xxx-xxxx"
Output:
Account Environment TenantId TenantDomain AccountType
------- ----------- -------- ------------ -----------
xxxxx-xxxxx-xxxx-xxxx-xxxxxxxx AzureCloud xxxxxx-59ed-466e-xx59-030448046197 5e0b361b-59ed-466e-8759-xxxxxxxxxx AccessToken
So above works but would like to do the same with python.
The docs are all over the place with mapping client_id to application_id and such.
Does anyone have a way to connect with python with the same information from the above command?
CodePudding user response:
Install the MSAL for Python package. You can find MSAL Python on Pypi.
pip install msal
Acquiring tokens with MSAL Python follows this 3-step pattern. This is the high level conceptual pattern. There will be some variations for different flows.
They are demonstrated in the runnable samples.
More info: https://learn.microsoft.com/en-us/python/api/overview/azure/active-directory?view=azure-python