<?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: Power Bi REST API - 401 Authorization error when using Service Principals in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/831953#M21232</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having the same problem and believe I have applied the Service Principal as admin. I am using the following tutorial which seems to provide for that step specifically in step 5:&amp;nbsp;&amp;nbsp;&lt;A href="https://cloudarchitected.com/2019/03/embedding-power-bi-content-with-a-service-principal/" target="_blank"&gt;https://cloudarchitected.com/2019/03/embedding-power-bi-content-with-a-service-principal/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not immediately proficient in powershell or the Power BI API so it would be great if someone could confirm that step should have provided the correct outcome or if / how I can confirm further that I have implemented the resolution provided above correctly, or if not perhaps assist with script sample?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks for your help.&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Oct 2019 02:03:22 GMT</pubDate>
    <dc:creator>rvn</dc:creator>
    <dc:date>2019-10-30T02:03:22Z</dc:date>
    <item>
      <title>Power Bi REST API - 401 Authorization error when using Service Principals</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/627827#M18607</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been following &lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/embed-sample-for-customers" target="_blank" rel="noopener"&gt;this guide&lt;/A&gt; while setting up my app. Everything works fine if I use password credentials flow and supply my own userame/password to get an access token. However, if I try to use client credentials flow, I get a 401 whenever I call any power bi endpoint.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried downloading the sample application provided &lt;A href="https://github.com/guyinacube/PowerBI-Developer-Samples" target="_blank" rel="noopener"&gt;here&lt;/A&gt;. Using "App Owns Data", I get the same results. If I use MasterUser (username/pass), everything works fine. But if I use &lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/embed-service-principal" target="_self"&gt;ServicePrincipal&lt;/A&gt; (cliend_id/client_secret), I get 401.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand that this is a new feature and it's just a public preview. But has anyone had any luck getting it to work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;More details:&lt;/P&gt;&lt;P&gt;Azure:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;App registered with all available permissions for Power Bi Service.&lt;/LI&gt;&lt;LI&gt;Security group created with App as member.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Power BI:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Workspace (new type) created.&lt;/LI&gt;&lt;LI&gt;Service principal enabled in admin panel and Azure security group (with App as member) added.&lt;/LI&gt;&lt;LI&gt;The security group is added as admin in the workspace access panel.&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Wed, 20 Feb 2019 12:49:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/627827#M18607</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-20T12:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: Power Bi REST API - 401 Authorization error when using Service Principals</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/628951#M18616</link>
      <description>&lt;P&gt;I was able to get the auth token by using the service principal (client id, secret) however when I use the token and query (getReports) etc, it fails with 401.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The trick to get the token was that the APP needs to be&amp;nbsp;"Server-side web application" instead of "native".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However I believe the permissions are not being assigned when the app/security group is added to the Power BI API access.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 15:17:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/628951#M18616</guid>
      <dc:creator>Rahman</dc:creator>
      <dc:date>2019-02-21T15:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: Power Bi REST API - 401 Authorization error when using Service Principals</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/629105#M18619</link>
      <description>&lt;P&gt;Then you're in the same situation as me &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I also manage to get the access token, but i can't use it.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 19:05:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/629105#M18619</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-21T19:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Power Bi REST API - 401 Authorization error when using Service Principals</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/629360#M18623</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I made the Service Principal work in the "App Owns Data" demo and with the Rest APIs. It seems everything &lt;SPAN style="background-color: #f6d5d9;"&gt;is&amp;nbsp;&lt;/SPAN&gt;set up correctly according to your description. Some suggestions are as follows.&lt;/P&gt;
&lt;P&gt;1. Add the Service Principal as an admin in the workspace directly rather than add the security group. Please refer to article 5 in&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/embed-service-principal#get-started-with-a-service-principal" target="_self"&gt;embed-service-principal#get-started-with-a-service-principal&lt;/A&gt;. We should use the Object ID.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://ibb.co/BCjzp9B" target="_blank"&gt;&lt;IMG src="https://ip1.i.lithium.com/3e3e94b718a7bdf7ed612d21ada408e1c011cb55/68747470733a2f2f692e6962622e636f2f704c5a303753642f506f7765722d42692d524553542d4150492d3430312d417574686f72697a6174696f6e2d6572726f722d7768656e2d7573696e672d536572766963652d5072696e636970616c732e706e67" border="0" alt="Power-Bi-REST-API-401-Authorization-error-when-using-Service-Principals" /&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;2. The Service Principal inherit permission from the tenant rather than the Azure App permissions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;gt;&amp;gt;Service principals inherit the permissions for all Power BI tenant settings from their security group. To restrict permissions create a dedicated security group for service principals and add it to the 'Except specific security groups' list for the relevant, enabled Power BI settings.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;3. I'm afraid you can't call the Admin REST API if the Service Principal doesn't have the permission.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 05:11:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/629360#M18623</guid>
      <dc:creator>v-jiascu-msft</dc:creator>
      <dc:date>2019-02-22T05:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Power Bi REST API - 401 Authorization error when using Service Principals</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/629559#M18628</link>
      <description>&lt;P&gt;Thank you! Your first comment gave me an idea. My issue was that i did not add the Service Principal itself as Admin, i added the Security Group it belonged to. I was not able to choose a service pricipal in the UI when adding access permissions. Instead, i had to use &lt;A href="https://docs.microsoft.com/sv-se/rest/api/power-bi/groups/addgroupuser" target="_blank" rel="noopener"&gt;the API&lt;/A&gt; and now everything is working fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 08:30:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/629559#M18628</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-22T08:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Power Bi REST API - 401 Authorization error when using Service Principals</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/629571#M18629</link>
      <description>&lt;P&gt;It's my pleasure. I'm glad you made it work. Thanks for sharing the details. This feature is under preview.&amp;nbsp;I believe it will be easy to use when it's generally&amp;nbsp;available.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 08:35:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/629571#M18629</guid>
      <dc:creator>v-jiascu-msft</dc:creator>
      <dc:date>2019-02-22T08:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: Power Bi REST API - 401 Authorization error when using Service Principals</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/831953#M21232</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having the same problem and believe I have applied the Service Principal as admin. I am using the following tutorial which seems to provide for that step specifically in step 5:&amp;nbsp;&amp;nbsp;&lt;A href="https://cloudarchitected.com/2019/03/embedding-power-bi-content-with-a-service-principal/" target="_blank"&gt;https://cloudarchitected.com/2019/03/embedding-power-bi-content-with-a-service-principal/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not immediately proficient in powershell or the Power BI API so it would be great if someone could confirm that step should have provided the correct outcome or if / how I can confirm further that I have implemented the resolution provided above correctly, or if not perhaps assist with script sample?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks for your help.&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 02:03:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/831953#M21232</guid>
      <dc:creator>rvn</dc:creator>
      <dc:date>2019-10-30T02:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Power Bi REST API - 401 Authorization error when using Service Principals</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/971609#M22669</link>
      <description>&lt;P&gt;After banging my head against the wall for what feels like days I solved my problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I migrated from a master user where I used an authority url of:&amp;nbsp;&lt;A href="https://login.microsoftonline.com/common" target="_blank"&gt;https://login.microsoftonline.com/common&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I switched to a service principal I had to change the authority url to:&amp;nbsp;&lt;A href="https://login.microsoftonline.com/{my" target="_blank"&gt;https://login.microsoftonline.com/{my&lt;/A&gt; AAD tenant id}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which then allowed my API calls to work.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 03:10:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/971609#M22669</guid>
      <dc:creator>boylec</dc:creator>
      <dc:date>2020-03-13T03:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: Power Bi REST API - 401 Authorization error when using Service Principals</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/1800704#M29134</link>
      <description>&lt;P&gt;Make sure you target a new workspace and not the default "My Workspace" and check you have assigned all relevant permissions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See my blog hope it helps :&amp;nbsp;&lt;A href="https://blog.joshduxbury.co.uk/2021/04/22/import-data-into-power-bi-using-rest-logic-apps/" target="_blank"&gt;https://blog.joshduxbury.co.uk/2021/04/22/import-data-into-power-bi-using-rest-logic-apps/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 14:51:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/1800704#M29134</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-22T14:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Power Bi REST API - 401 Authorization error when using Service Principals</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/2843211#M39268</link>
      <description>&lt;P&gt;Similar problem... I believe its related with the option&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Allow Service Principal to use Power BI APIs.&lt;/STRONG&gt; on the PowerBI Tenant settings. That is mentioned that has to be activated in&amp;nbsp;&lt;A href="https://sqlitybi.com/authenticating-power-bi-xmla-endpoint-using-service-principal/" target="_blank"&gt;https://sqlitybi.com/authenticating-power-bi-xmla-endpoint-using-service-principal/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 19:08:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/2843211#M39268</guid>
      <dc:creator>aechague</dc:creator>
      <dc:date>2022-10-14T19:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: Power Bi REST API - 401 Authorization error when using Service Principals</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/3124569#M41679</link>
      <description>&lt;P&gt;The same problem. Give all rights to app in Azure. Enable "Allow Service Principal to use Power BI APIs" but still get 401 Eror. Helpppp&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 16:10:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/3124569#M41679</guid>
      <dc:creator>VSmart</dc:creator>
      <dc:date>2023-03-10T16:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: Power Bi REST API - 401 Authorization error when using Service Principals</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/3503590#M45166</link>
      <description>&lt;P&gt;Hi all, this resolved the issue for me:&lt;BR /&gt;&lt;BR /&gt;1. Enable the tenant setting "Allow service principals to use Power BI APIs".&lt;BR /&gt;2. Create an AAD user group.&lt;BR /&gt;3. Create a Service Principal account and add it to the AAD user group.&lt;/P&gt;&lt;P&gt;4. Assign the AAD user group to the workspace access.&lt;BR /&gt;5. &lt;STRONG&gt;IMPORTANT!&lt;/STRONG&gt; &lt;STRONG&gt;Assign Service Principal account to workspace access directly!&lt;/STRONG&gt; So that you would have both AAD user group and Service Principal in the wotkspace access.&lt;/P&gt;&lt;P&gt;6. After that you can remove the Service Principal direct assignment, but the access will still work through AAD user group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe it's a bug, but something is deinitely happening in the background with service principals and AAD user groups access.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2023 02:29:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-Bi-REST-API-401-Authorization-error-when-using-Service/m-p/3503590#M45166</guid>
      <dc:creator>alexgor87</dc:creator>
      <dc:date>2023-10-30T02:29:45Z</dc:date>
    </item>
  </channel>
</rss>

