Forum Discussion

Toi69___'s avatar
Toi69___
Frequent Visitor
1 year ago
Solved

how to get data about users from powerbi rest api without been administrator

Hello all, I looking for a solution to get evant activity ou audit log from power bi rest api or azure. I created a application on azure, a service principal and a secret. A have thoses permissi...
  • Toi69___'s avatar
    Toi69___
    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 msal
    import requests
    import 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,
            authority=f"https://login.microsoftonline.com/{TENANT_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 
  • v-lgarikapat's avatar
    v-lgarikapat
    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,
    Lakshmi

    Solved: Re: Extracting power BI Usage logs without powerBI... - Microsoft Fabric Community

    Microsoft Graph permissions reference - Microsoft Graph | Microsoft Learn