Forum Discussion
how to get data about users from powerbi rest api without been administrator
- 1 year ago
Thank you for this overview.
I still have a question when you say :
"Set up a separate service principal account with the required role and permissions, and use that identity for your API calls."
I do not understand beacause when a make ma api call, i use my service principal informations to get data.Here this is my python witch give me the token :
import msalimport requestsimport pandas as pd# === Paramètres ===TENANT_ID = 'my tenant id'CLIENT_ID = 'my client id of my enterprise application'CLIENT_SECRET = 'My secret '# === Authentification ===def get_graph_access_token():app = msal.ConfidentialClientApplication(client_id=CLIENT_ID,client_credential=CLIENT_SECRET)result = app.acquire_token_for_client(scopes=GRAPH_SCOPE)if "access_token" in result:return result['access_token']else:raise Exception(f"Échec de l'authentification : {result}")# === Script principal ===if __name__ == "__main__":token = get_graph_access_token()With this a can get data for microsoft graph api in is v1.0 version but for the auditlog i need to use the beta version and at this time i receive a error.
So if i understand i receive a token witch is connecting to my service principal so in this case a should not have error of permissions ?
Do i understand correct ?
If not coult you give me the solution to use my service principal correcty ?
Thank you Poojara_D12 - 1 year ago
HI Toi69___ ,
I have included the previously resolved thread and learning documents. They may help you resolve the issue
We truly appreciate your continued engagement and thank you for being an active and valued member of the community.
If you're still experiencing any challenges, please don’t hesitate to reach out we’d be more than happy to assist you further.
We look forward to hearing from you.
Best regards,
LakshmiSolved: Re: Extracting power BI Usage logs without powerBI... - Microsoft Fabric Community
Microsoft Graph permissions reference - Microsoft Graph | Microsoft Learn
Hi Toi69___ ,
You're encountering errors when trying to access Power BI activity events or Azure audit logs via the REST API because, even though your Azure application has the correct API permissions (such as AuditLog.Read.All, Directory.Read.All, and Tenant.Read.All), accessing this type of sensitive organizational data requires elevated privileges. Specifically, Microsoft enforces that only users with either the Power BI Service Administrator role or Microsoft 365 Global Administrator role can retrieve audit logs and activity event data.
This applies whether you're using delegated permissions (on behalf of a signed-in user) or application permissions via a service principal. Without one of these admin roles, the APIs will block access, regardless of the app's permission grants.
To move forward, you would either need an administrator to grant consent on behalf of the organization and assign the appropriate admin role to your service account, or request that an admin run the query and provide the data you need. Unfortunately, there's no workaround to bypass this requirement, as it's a security restriction built into Microsoft’s auditing and compliance controls.