<?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 API with service principal - 401 unauthorized in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1834506#M29371</link>
    <description>&lt;P&gt;Oh, that's easy then. Your POST is wrong. Didnt spot it the first time round because it was right at the top &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt; It &lt;STRONG&gt;must&lt;/STRONG&gt; have the tenant ID in it, not 'common'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use:&lt;/P&gt;&lt;P&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;&lt;/P&gt;</description>
    <pubDate>Mon, 10 May 2021 20:53:03 GMT</pubDate>
    <dc:creator>DavidCousinsT</dc:creator>
    <dc:date>2021-05-10T20:53:03Z</dc:date>
    <item>
      <title>Power BI API with service principal - 401 unauthorized</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1736347#M28524</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;recently I have been trying to make Power BI APIs work with service principal authentication. All steps mentioned in this article&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/embedded/embed-service-principal" target="_blank" rel="noopener"&gt;https://docs.microsoft.com/en-us/power-bi/developer/embedded/embed-service-principal&lt;/A&gt;&amp;nbsp;are done:&lt;/P&gt;&lt;P&gt;- an Azure AD app is registered (service principal created)&lt;/P&gt;&lt;P&gt;- an AD security group is created, the app is added to this group&lt;/P&gt;&lt;P&gt;- a Power BI admin has enabled service principal access in the admin portal&lt;/P&gt;&lt;P&gt;- the service principal and the security group are added to the workspace (and granted the admin role)&lt;/P&gt;&lt;P&gt;I am able to generate an access token using the POST method for&amp;nbsp;&lt;A href="https://login.microsoftonline.com/common/oauth2/token" target="_blank" rel="noopener"&gt;https://login.microsoftonline.com/common/oauth2/token&lt;/A&gt;&amp;nbsp;(screenshot below).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="token.PNG" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/478974i4C826C08F7A9A1E5/image-size/large?v=v2&amp;amp;px=999" role="button" title="token.PNG" alt="token.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The issue is that whenever this token is used for any further calls (I have tried both non-admin and admin APIs - when it comes to admin ones, I only tested the supported APIS - can be seen in this article &lt;A href="https://docs.microsoft.com/en-us/power-bi/admin/read-only-apis-service-principal-authentication" target="_blank" rel="noopener"&gt;https://docs.microsoft.com/en-us/power-bi/admin/read-only-apis-service-principal-authentication&lt;/A&gt;), I am shown the 401 unauthorized error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So my question is: did I overlook some security setting perhaps? Our company uses MFA, but service principals do not use that from what I have found on this forum/in the documentation. Or is the generated token invalid somehow?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Mar 2021 11:20:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1736347#M28524</guid>
      <dc:creator>matoxin</dc:creator>
      <dc:date>2021-03-22T11:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI API with service principal - 401 unauthorized</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1738204#M28544</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What API Permissions are set up in your App Registration for Power BI? Everything else seems ok.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Mar 2021 04:02:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1738204#M28544</guid>
      <dc:creator>Everton</dc:creator>
      <dc:date>2021-03-23T04:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI API with service principal - 401 unauthorized</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1738809#M28548</link>
      <description>&lt;P&gt;Hello, at the moment, the app has the following API permissions:&lt;/P&gt;&lt;P&gt;- Dataset.ReadAll&lt;/P&gt;&lt;P&gt;- Report.ReadAll&lt;/P&gt;&lt;P&gt;- Workspace.ReadAll&lt;/P&gt;&lt;P&gt;I assume that Tenant.ReadAll should be added as well - is that correct?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Mar 2021 08:33:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1738809#M28548</guid>
      <dc:creator>matoxin</dc:creator>
      <dc:date>2021-03-23T08:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI API with service principal - 401 unauthorized</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1744759#M28598</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/291986"&gt;@matoxin&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/embedded/embed-service-principal#considerations-and-limitations" target="_self"&gt;Considerations and limitations&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you checked these considerations and limitations?&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>Thu, 25 Mar 2021 07:28:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1744759#M28598</guid>
      <dc:creator>v-lionel-msft</dc:creator>
      <dc:date>2021-03-25T07:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI API with service principal - 401 unauthorized</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1744902#M28602</link>
      <description>&lt;P&gt;Hello Lionel,&lt;/P&gt;&lt;P&gt;yes, we have checked that article multiple times - to make sure we have not forgotten anything.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 08:10:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1744902#M28602</guid>
      <dc:creator>matoxin</dc:creator>
      <dc:date>2021-03-25T08:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI API with service principal - 401 unauthorized</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1817320#M29253</link>
      <description>&lt;P&gt;I'm curious if you were ever able to resolve this - I'm having the same issue.&amp;nbsp; 401 unauthorized on all calls.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 18:10:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1817320#M29253</guid>
      <dc:creator>Mthompson1984</dc:creator>
      <dc:date>2021-04-30T18:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI API with service principal - 401 unauthorized</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1832025#M29338</link>
      <description>&lt;P&gt;Try getting the token with your resource set as:&lt;/P&gt;&lt;P&gt;&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;&lt;/P&gt;&lt;P&gt;Also make sure that your tenant admin has added the AAD security group to the "specific security group" list in Power BI.&lt;/P&gt;</description>
      <pubDate>Sun, 09 May 2021 16:56:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1832025#M29338</guid>
      <dc:creator>DavidCousinsT</dc:creator>
      <dc:date>2021-05-09T16:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI API with service principal - 401 unauthorized</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1832788#M29354</link>
      <description>&lt;P&gt;No, not yet - still trying to figure this out. Will update the thread if I find anything.&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 07:25:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1832788#M29354</guid>
      <dc:creator>matoxin</dc:creator>
      <dc:date>2021-05-10T07:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI API with service principal - 401 unauthorized</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1833691#M29365</link>
      <description>&lt;P&gt;When I tried getting the token with the resource set to&amp;nbsp;&lt;A href="https://analysis.windows.net/powerbi/api/.default" target="_blank" rel="nofollow noopener noreferrer"&gt;https://analysis.windows.net/powerbi/api/.default&lt;/A&gt;, it threw the following error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="matoxin_0-1620649897103.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/511512i317B6D361FCC1C60/image-size/medium?v=v2&amp;amp;px=400" role="button" title="matoxin_0-1620649897103.png" alt="matoxin_0-1620649897103.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The AAD security group (and also the service principal) has been added to the specific security group list in our Power BI workspace.&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 12:32:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1833691#M29365</guid>
      <dc:creator>matoxin</dc:creator>
      <dc:date>2021-05-10T12:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI API with service principal - 401 unauthorized</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1834506#M29371</link>
      <description>&lt;P&gt;Oh, that's easy then. Your POST is wrong. Didnt spot it the first time round because it was right at the top &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt; It &lt;STRONG&gt;must&lt;/STRONG&gt; have the tenant ID in it, not 'common'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use:&lt;/P&gt;&lt;P&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;&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 20:53:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1834506#M29371</guid>
      <dc:creator>DavidCousinsT</dc:creator>
      <dc:date>2021-05-10T20:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI API with service principal - 401 unauthorized</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1834512#M29372</link>
      <description>&lt;P&gt;Ah, you've been using a different API. Not sure that one would ever work. Heres the working oauth one I have: &lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="PBI Get Bearer.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/511742i3A488E537349F669/image-size/large?v=v2&amp;amp;px=999" role="button" title="PBI Get Bearer.png" alt="PBI Get Bearer.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 21:03:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1834512#M29372</guid>
      <dc:creator>DavidCousinsT</dc:creator>
      <dc:date>2021-05-10T21:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI API with service principal - 401 unauthorized</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1835450#M29375</link>
      <description>&lt;P&gt;Thank you so much, this actually worked, I was finally able to generate a bearer token without any error messages.&lt;/P&gt;&lt;P&gt;The issue now is that whatever call I make using this token, I get the following error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="matoxin_0-1620720098230.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/512032i6A588FD559702BAD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="matoxin_0-1620720098230.png" alt="matoxin_0-1620720098230.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I tried finding more information about this and everything points to some issue with permissions, but I cannot figure out what's wrong (I have tested both non-admin and some of the supported admin calls). Please, do you have any idea what might be the problem?&lt;/P&gt;&lt;P&gt;UPDATE: some non-admin calls actually work, but I was not able to make any of the admin ones work properly. I have checked Azure again to make sure I have all the correct permissions assigned, and it seems to be the case:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="matoxin_1-1620721072043.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/512054i32D34D152DC8F365/image-size/medium?v=v2&amp;amp;px=400" role="button" title="matoxin_1-1620721072043.png" alt="matoxin_1-1620721072043.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is anything missing?&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 08:18:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/1835450#M29375</guid>
      <dc:creator>matoxin</dc:creator>
      <dc:date>2021-05-11T08:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI API with service principal - 401 unauthorized</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/2719741#M38109</link>
      <description>&lt;P&gt;Hi, we are experiencing a similar problem. Were you able to solve the issue?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2022 09:27:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/2719741#M38109</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-23T09:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI API with service principal - 401 unauthorized</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/3604857#M46564</link>
      <description>&lt;P&gt;Hi, I meet tyhe same issue, could you please share your solution, thanks&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2023 07:22:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/3604857#M46564</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-12-28T07:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI API with service principal - 401 unauthorized</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/3957255#M52925</link>
      <description>&lt;P&gt;A long time has passed, do you remember how to add AD security group to PowerBI?&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 08:56:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API-with-service-principal-401-unauthorized/m-p/3957255#M52925</guid>
      <dc:creator>q2bi</dc:creator>
      <dc:date>2024-05-29T08:56:44Z</dc:date>
    </item>
  </channel>
</rss>

