<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: PowerBINotAuthorizedException exception when executing admin/activityevents API in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/PowerBINotAuthorizedException-exception-when-executing-admin/m-p/2097657#M32032</link>
    <description>&lt;P&gt;I am also getting the following response&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"error"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"code"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;"PowerBINotAuthorizedException"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"pbi.error"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"code"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;"PowerBINotAuthorizedException"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"parameters"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;{},&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"details"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;[],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"exceptionCulprit"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;1&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Got the auth token by giving resource:&amp;nbsp;&lt;A href="https://analysis.windows.net/powerbi/api" target="_blank"&gt;https://analysis.windows.net/powerbi/api&lt;/A&gt;. Did anyone find the solution for it for the get activity API&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 24 Sep 2021 19:11:02 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-09-24T19:11:02Z</dc:date>
    <item>
      <title>PowerBINotAuthorizedException exception when executing admin/activityevents API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBINotAuthorizedException-exception-when-executing-admin/m-p/1585980#M27089</link>
      <description>&lt;P&gt;I am trying to collect powerbi usage via the&amp;nbsp;&lt;SPAN&gt;admin/activityevents API but I get&amp;nbsp;PowerBINotAuthorizedException in the response.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Steps followed to generate the token:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Created an azure AD app and assigned Tenant.Read.All and Tenant.ReadWrite.All permissions to it and granted the permissions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Generated the token using&amp;nbsp;oauth2/v2.0/token api where I used grant_type as&amp;nbsp;client_credentials and scope as &lt;A href="https://analysis.windows.net/powerbi/api/.default" target="_blank" rel="noopener"&gt;https://analysis.windows.net/powerbi/api/.default&lt;/A&gt;. I got&amp;nbsp;&lt;SPAN&gt;PowerBINotAuthorizedException exception.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Further I tried to use Service Principal to hit the API using below steps:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1) Added new security group and added the App as member of it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2) In PowerBi Tenant settings, allowed ServicePrincipal to hit PowerBI and also ReadOnly admin APIs.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Generated the token and hit the activityevent api but still got same&amp;nbsp;PowerBINotAuthorizedException.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Though I was able to hit the API with grant_type&amp;nbsp;password, but we do not want to use that approach.&lt;BR /&gt;&lt;BR /&gt;What am I missing? Is it possible to use app authentication/service principal authentication to hit admin APIs specifically activityevents api?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My main usecase is to get the last activity date of every powerbi user.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 08:52:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBINotAuthorizedException-exception-when-executing-admin/m-p/1585980#M27089</guid>
      <dc:creator>Sreenatha</dc:creator>
      <dc:date>2021-01-07T08:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBINotAuthorizedException exception when executing admin/activityevents API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBINotAuthorizedException-exception-when-executing-admin/m-p/1589346#M27163</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/278843"&gt;@Sreenatha&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you can refer to the link.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://powerusers.microsoft.com/t5/Building-Flows/Power-BI-Connector-PowerBINotAuthorizedException/td-p/746073" target="_self"&gt;Power BI Connector PowerBINotAuthorizedException&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;BR /&gt;Lionel Chen&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;, then please consider&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 07:30:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBINotAuthorizedException-exception-when-executing-admin/m-p/1589346#M27163</guid>
      <dc:creator>v-lionel-msft</dc:creator>
      <dc:date>2021-01-11T07:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBINotAuthorizedException exception when executing admin/activityevents API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBINotAuthorizedException-exception-when-executing-admin/m-p/1952854#M30480</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/278843"&gt;@Sreenatha&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did you ever get this&amp;nbsp;&lt;EM&gt;PowerBINotAuthorizedException&amp;nbsp;&lt;/EM&gt;error resolved.&lt;/P&gt;&lt;P&gt;I am currently trying to extract audit logs using service principle for automation and performed all configurations same like you and running into not authorized issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PowerBINotAuthorizedException&lt;/PRE&gt;&lt;P&gt;When I use the token generated by my userid and password, the generated token was working and extracting logs. running into issues when token generated by service principle is throwing not authorized error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 17:52:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBINotAuthorizedException-exception-when-executing-admin/m-p/1952854#M30480</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-12T17:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBINotAuthorizedException exception when executing admin/activityevents API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBINotAuthorizedException-exception-when-executing-admin/m-p/2097657#M32032</link>
      <description>&lt;P&gt;I am also getting the following response&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"error"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"code"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;"PowerBINotAuthorizedException"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"pbi.error"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"code"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;"PowerBINotAuthorizedException"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"parameters"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;{},&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"details"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;[],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"exceptionCulprit"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;1&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Got the auth token by giving resource:&amp;nbsp;&lt;A href="https://analysis.windows.net/powerbi/api" target="_blank"&gt;https://analysis.windows.net/powerbi/api&lt;/A&gt;. Did anyone find the solution for it for the get activity API&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 24 Sep 2021 19:11:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBINotAuthorizedException-exception-when-executing-admin/m-p/2097657#M32032</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-24T19:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBINotAuthorizedException exception when executing admin/activityevents API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBINotAuthorizedException-exception-when-executing-admin/m-p/2097679#M32033</link>
      <description>&lt;P&gt;Hi Guys&lt;/P&gt;&lt;P&gt;I wanted to share information about the automation of importing PowerBI audit logs using Application Permissions or Service Principle from PowerBI service right from App registration to using MSAL python library. There are several documentations available in Microsoft site with different configurations, but unless we search them with specific term and follow the instructions I was not able to resolve the authentication issues.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since most of the company's we use multifactor authentication, delegated permissions will not allow any python/.net application to get automated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first and foremost thing we need to perform is registering an app in Azure portal or using app registration using following link&amp;nbsp;&lt;A href="https://dev.powerbi.com/apps" target="_blank"&gt;https://dev.powerbi.com/apps&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;App Registration:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Perform app registration steps only as mentioned in the following blog (&lt;A href="https://carldesouza.com/how-to-register-an-azure-app-to-use-with-power-bi/)" target="_blank"&gt;https://carldesouza.com/how-to-register-an-azure-app-to-use-with-power-bi/)&lt;/A&gt; and DO NOT set any permissions. Since these permissions didn't worked while authenticating the token generated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Permissions:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;After assigning Tenant.Read.All make sure you are &lt;STRONG&gt;Not&lt;/STRONG&gt; accepting the admin consent as suggested by below documentation.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/power-bi/admin/read-only-apis-service-principal-authentication" target="_blank"&gt;https://docs.microsoft.com/en-us/power-bi/admin/read-only-apis-service-principal-authentication&lt;/A&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create Client Secret and keep this handy.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Making API calls using MSAL library:&lt;/STRONG&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;MSAL client secret example can be found here&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;A href="https://github.com/AzureAD/microsoft-authentication-library-for-python/blob/dev/sample/confidential_client_secret_sample.py" target="_blank"&gt;https://github.com/AzureAD/microsoft-authentication-library-for-python/blob/dev/sample/confidential_client_secret_sample.py&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create json parameter file(Parameters.json) with following configurations and endpoints&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;{&amp;nbsp;&amp;nbsp;&amp;nbsp; "authority": "&lt;A href="https://login.microsoftonline.com/Enter%20you%20tenantID%20Here%20" target="_blank"&gt;https://login.microsoftonline.com/Enter you tenantID Here &lt;/A&gt;",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "client_id": "Enter ClientID of the app you have Registered",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "scope": ["&lt;A href="https://analysis.windows.net/powerbi/api/.default" target="_blank"&gt;https://analysis.windows.net/powerbi/api/.default&lt;/A&gt;"],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "secret": "Enter Client Secret you created above",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "endpoint": "&lt;A href="https://api.powerbi.com/v1.0/myorg/admin/groups?$expand=datasets,dataflows,reports,dashboards,users&amp;amp;$top=5000" target="_blank"&gt;https://api.powerbi.com/v1.0/myorg/admin/groups?$expand=datasets,dataflows,reports,dashboards,users&amp;amp;$top=5000&lt;/A&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Install necessary MSAL library for Python using "pip install msal" in your command prompt&lt;/LI&gt;&lt;LI&gt;You can get the code I have used to generate user activity&amp;nbsp; data from below git link. Even though I have mentioned an endpoint in parameters file I am deriving my required user activity endpoint in Python program since I have to generate several extracts with several endpoints and I want to use a single parameter files for all those extracts.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: There might be better ways to program in Python to extract the data from these API's but this is what I have developed which is working successfully.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 19:34:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBINotAuthorizedException-exception-when-executing-admin/m-p/2097679#M32033</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-24T19:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBINotAuthorizedException exception when executing admin/activityevents API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBINotAuthorizedException-exception-when-executing-admin/m-p/2100804#M32085</link>
      <description>&lt;P&gt;Here is the content I have posted after finally resolving authentication issues in rest api and making the program work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Service/Automate-importing-PowerBI-audit-logs-using-Application-or/m-p/2100799#M140411" target="_blank"&gt;https://community.powerbi.com/t5/Service/Automate-importing-PowerBI-audit-logs-using-Application-or/m-p/2100799#M140411&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Sep 2021 16:41:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBINotAuthorizedException-exception-when-executing-admin/m-p/2100804#M32085</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-27T16:41:34Z</dc:date>
    </item>
  </channel>
</rss>

