<?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: Rest API with Service Principal - Can't get past Error 403 in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Rest-API-with-Service-Principal-Can-t-get-past-Error-403/m-p/2627980#M37252</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/410431"&gt;@risDS&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't tell for sure, but I guess&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;"Tenant.ReadWrite.All" isn't enough, it might be confusing but it doesn't contain all other scopes. For example if a certain API requires "Report.ReadWrite.All" then it will fail for you.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Each API has it's specific scopes requirement, and if the scope is missing from the token the API will fail.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Jul 2022 14:56:31 GMT</pubDate>
    <dc:creator>AmosHersch</dc:creator>
    <dc:date>2022-07-08T14:56:31Z</dc:date>
    <item>
      <title>Rest API with Service Principal - Can't get past Error 403</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Rest-API-with-Service-Principal-Can-t-get-past-Error-403/m-p/2627335#M37247</link>
      <description>&lt;P&gt;Hello everybody,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I seem to require some help on the subject, after several hours of searches and experimentation, I still cannot seem to solve my issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use the API to programmatically add rows to a dataset. To do so, I :&lt;/P&gt;&lt;P&gt;- Created an application in my AAD, with an associated secret and gave it the permissions PowerBI "Tenant.ReadWrite.All" and granted the permission with an admin account&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="risDS_0-1657273967763.png" style="width: 790px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/745146iAB868F5F0DA14FD7/image-dimensions/790x443?v=v2" width="790" height="443" role="button" title="risDS_0-1657273967763.png" alt="risDS_0-1657273967763.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;- Allowed service principals to use Power BI APIs through the Admin Portal&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="risDS_1-1657274050324.png" style="width: 705px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/745147i61B179EB435FD6B1/image-dimensions/705x397?v=v2" width="705" height="397" role="button" title="risDS_1-1657274050324.png" alt="risDS_1-1657274050324.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;- Added the service principal account to a newly created Workspace (first as Member, now as Admin)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="risDS_2-1657274097835.png" style="width: 705px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/745148i6EC4A5476711D9C8/image-dimensions/705x394?v=v2" width="705" height="394" role="button" title="risDS_2-1657274097835.png" alt="risDS_2-1657274097835.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Used OAuth 2 authentication flow to get the token (Auth URL : &lt;SPAN&gt;&lt;A href="https://login.microsoftonline.com/{TenantId}/oauth2/v2.0/token," target="_blank"&gt;https://login.microsoftonline.com/{TenantId}/oauth2/v2.0/token,&lt;/A&gt; scope : &lt;A href="https://analysis.windows.net/powerbi/api/.default" target="_self"&gt;https://analysis.windows.net/powerbi/api/.default&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN&gt; )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;- Now the token seems perfectly valid :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="risDS_3-1657274242367.png" style="width: 487px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/745152i71781DB4BE9AC603/image-dimensions/487x393?v=v2" width="487" height="393" role="button" title="risDS_3-1657274242367.png" alt="risDS_3-1657274242367.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;- But trying to contact any endpoint ends up with a 403 Forbidden response (ex : &lt;SPAN&gt;&lt;A href="https://api.powerbi.com/v1.0/myorg/datasets/" target="_blank"&gt;https://api.powerbi.com/v1.0/myorg/datasets/&lt;/A&gt;&lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I missing here ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance, I hope you will help me figure this out !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2022 09:59:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Rest-API-with-Service-Principal-Can-t-get-past-Error-403/m-p/2627335#M37247</guid>
      <dc:creator>risDS</dc:creator>
      <dc:date>2022-07-08T09:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: Rest API with Service Principal - Can't get past Error 403</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Rest-API-with-Service-Principal-Can-t-get-past-Error-403/m-p/2627980#M37252</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/410431"&gt;@risDS&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't tell for sure, but I guess&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;"Tenant.ReadWrite.All" isn't enough, it might be confusing but it doesn't contain all other scopes. For example if a certain API requires "Report.ReadWrite.All" then it will fail for you.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Each API has it's specific scopes requirement, and if the scope is missing from the token the API will fail.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2022 14:56:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Rest-API-with-Service-Principal-Can-t-get-past-Error-403/m-p/2627980#M37252</guid>
      <dc:creator>AmosHersch</dc:creator>
      <dc:date>2022-07-08T14:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: Rest API with Service Principal - Can't get past Error 403</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Rest-API-with-Service-Principal-Can-t-get-past-Error-403/m-p/2635752#M37318</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/410431"&gt;@risDS&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;As&amp;nbsp;AmosHersch&amp;nbsp;said, the tenant permission may not be suitable for all API usages. They will also require the contents level permissions. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;For example, the dataset API requires the permissions of the dataset, the report API will require the report permissions. You can find these additional requrenmenmt in the detailed API page 'scope' part.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;BTW, they may also require additional permissions or be limited used due to connection mode when you work on particular data sources. (e.g. Azure AS)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 08:37:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Rest-API-with-Service-Principal-Can-t-get-past-Error-403/m-p/2635752#M37318</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-07-13T08:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: Rest API with Service Principal - Can't get past Error 403</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Rest-API-with-Service-Principal-Can-t-get-past-Error-403/m-p/2635769#M37320</link>
      <description>&lt;P&gt;Thank you@Anonymous&lt;/a&gt; and &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/278935"&gt;@AmosHersch&lt;/a&gt; for your answers but they are incorrect.&lt;/P&gt;&lt;P&gt;As a matter of fact, using the C# connector (&lt;A href="https://github.com/microsoft/PowerBI-CSharp" target="_blank"&gt;https://github.com/microsoft/PowerBI-CSharp&lt;/A&gt;) with the exact same configuration, I am able to correctly carry through with the requests on all operations needed (so far Get groups, Get/Post Datasets, Post Rows in Datasets). It seems to be an issue with Postman authentication flow of some sort but I do not have time to investigate further as of now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 08:44:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Rest-API-with-Service-Principal-Can-t-get-past-Error-403/m-p/2635769#M37320</guid>
      <dc:creator>risDS</dc:creator>
      <dc:date>2022-07-13T08:44:17Z</dc:date>
    </item>
  </channel>
</rss>

