<?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: Use REST API as datasource with service principal in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Use-REST-API-as-datasource-with-service-principal/m-p/2946154#M40107</link>
    <description>&lt;P&gt;&lt;A href="https://github.com/migueesc123/PowerBIRESTAPI" target="_blank"&gt;GitHub - migueesc123/PowerBIRESTAPI: A Microsoft Power BI Data Connector or Power Query Connector for the Power BI REST API&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 03 Dec 2022 20:32:08 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2022-12-03T20:32:08Z</dc:date>
    <item>
      <title>Use REST API as datasource with service principal</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Use-REST-API-as-datasource-with-service-principal/m-p/2944824#M40095</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We want to use REST API of Power BI directly in Power BI Desktop and not via PowerShell.&lt;/P&gt;&lt;P&gt;I have a service principal which works in PowerShell.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I use REST API directly in Power BI Desktop with authenticating with a service principal.&lt;/P&gt;&lt;P&gt;Good to mention: I don't want to save the username and password a query.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2022 14:25:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Use-REST-API-as-datasource-with-service-principal/m-p/2944824#M40095</guid>
      <dc:creator>AslanAli</dc:creator>
      <dc:date>2022-12-02T14:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Use REST API as datasource with service principal</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Use-REST-API-as-datasource-with-service-principal/m-p/2946154#M40107</link>
      <description>&lt;P&gt;&lt;A href="https://github.com/migueesc123/PowerBIRESTAPI" target="_blank"&gt;GitHub - migueesc123/PowerBIRESTAPI: A Microsoft Power BI Data Connector or Power Query Connector for the Power BI REST API&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Dec 2022 20:32:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Use-REST-API-as-datasource-with-service-principal/m-p/2946154#M40107</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2022-12-03T20:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: Use REST API as datasource with service principal</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Use-REST-API-as-datasource-with-service-principal/m-p/2947461#M40119</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/480940"&gt;@AslanAli&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you can try below code to get access token by Rest API&amp;nbsp;&lt;SPAN class=""&gt;with Service Principal.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;() =&amp;gt;

 

let

    body = "client_id=" &amp;amp; #"App ID"

    &amp;amp; "&amp;amp;scope=https://analysis.windows.net/powerbi/api/.default&amp;amp;client_secret=" &amp;amp; #"App Secret"

    &amp;amp; "&amp;amp;grant_type=client_credentials",

    Data= Json.Document(Web.Contents("https://login.microsoftonline.com/"&amp;amp; TenantID &amp;amp; "/oauth2/v2.0/token/",

    [Headers=[#"Content-Type"="application/x-www-form-urlencoded"], Content=Text.ToBinary(body)])),

    access_token = Data[access_token]

in

    access_token​&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then add this token as a parameter into data source code. You may refer to below video to learn more details.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=N8qYRSqRz84" target="_self"&gt;&lt;SPAN&gt;Video: How to get access token and call Rest API by dynamic access token in Power BI Desktop?&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2022 06:44:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Use-REST-API-as-datasource-with-service-principal/m-p/2947461#M40119</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-12-05T06:44:43Z</dc:date>
    </item>
  </channel>
</rss>

