Hubert-Dudek
Databricks MVP

All just get group from Azure API when I am using Azure groups which is now popular with just in time provisioning.

authority_url = f"https://login.microsoftonline.com/{TENANT_ID}"
app = msal.ConfidentialClientApplication(CLIENT_ID, authority=authority_url, client_credential=CLIENT_SECRET)
token_result = app.acquire_token_for_client(scopes=["https://graph.microsoft.com/.default"])
if not token_result.get("access_token"):
    raise Exception("Failed to obtain Graph API token")
access_token = token_result["access_token"]
headers = {"Authorization": f"Bearer {access_token}", "Content-Type": "application/json"}

group_url = f"https://graph.microsoft.com/v1.0/groups/{GROUP_ID}/members/$ref"
resp_add = requests.get(group_url, headers=headers)

My blog: https://databrickster.medium.com/