<?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 in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API/m-p/605024#M18286</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/102669"&gt;@bsmithUI&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We need the access token to authenticate the request and do it like below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://ibb.co/wy7MTpw" target="_blank"&gt;&lt;IMG src="https://ip1.i.lithium.com/6bf8156494db8d95b6507597954d0f76e16fb90a/68747470733a2f2f692e6962622e636f2f585844533946332f506f7765722d42492d4150492e706e67" border="0" alt="Power-BI-API" /&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The problem is the token only survives 1 hour or more. It's hard to refresh the request. Maybe you can try the Python script with &lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-python" target="_self"&gt;ADAL&lt;/A&gt;.&lt;/P&gt;
&lt;PRE&gt;from adal import AuthenticationContext
import requests
import json
import pandas as pd


client_id = "a301********-98fe1dcde27e"  # application id
resource_uri = "https://analysis.windows.net/powerbi/api"  
user_name = "d*@microsoft.com"
user_password = "****"

auth_context = AuthenticationContext("https://login.microsoftonline.com/&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;Your_tenant_name&lt;/STRONG&gt;&lt;/FONT&gt;")
token_response = auth_context.acquire_token_with_username_password(resource_uri, user_name, user_password, client_id)
token = "Bearer " + token_response["accessToken"]

api_url = "https://api.powerbi.com/v1.0/myorg/admin/groups"
headers = {"Authorization": token}
r = requests.get(api_url, headers = headers)

result = pd.io.json.json_normalize(json.loads(r.text)["value"])&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://ibb.co/SB30328" target="_blank"&gt;&lt;IMG src="https://ip1.i.lithium.com/436e18878d8044a86969b1a99512f7d729cc4bc1/68747470733a2f2f692e6962622e636f2f4752356b35584c2f506f7765722d42492d415049322e706e67" border="0" alt="Power-BI-API2" /&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;</description>
    <pubDate>Mon, 21 Jan 2019 09:52:17 GMT</pubDate>
    <dc:creator>v-jiascu-msft</dc:creator>
    <dc:date>2019-01-21T09:52:17Z</dc:date>
    <item>
      <title>Power BI API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API/m-p/602459#M18254</link>
      <description>&lt;P&gt;Has anyone used the Power BI Rest API's as a data source in Power BI? I am looking to use it for some administrative reports. I am trying to get authenticated...I thought maybe Organizational Account, or Anonymous may pop open an O365 login window, but neither worked. I also tried Windows account thinking it might pass my Azure AD credentials to Power BI, but that didn't work either.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas? I am specifically thinking of this endpoint as a starting point:&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/rest/api/power-bi/admin/groups_getgroupsasadmin&amp;nbsp;" target="_blank"&gt;https://docs.microsoft.com/en-us/rest/api/power-bi/admin/groups_getgroupsasadmin&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any ideas!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2019 00:20:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API/m-p/602459#M18254</guid>
      <dc:creator>bsmithUI</dc:creator>
      <dc:date>2019-01-17T00:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API/m-p/605024#M18286</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/102669"&gt;@bsmithUI&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We need the access token to authenticate the request and do it like below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://ibb.co/wy7MTpw" target="_blank"&gt;&lt;IMG src="https://ip1.i.lithium.com/6bf8156494db8d95b6507597954d0f76e16fb90a/68747470733a2f2f692e6962622e636f2f585844533946332f506f7765722d42492d4150492e706e67" border="0" alt="Power-BI-API" /&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The problem is the token only survives 1 hour or more. It's hard to refresh the request. Maybe you can try the Python script with &lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-python" target="_self"&gt;ADAL&lt;/A&gt;.&lt;/P&gt;
&lt;PRE&gt;from adal import AuthenticationContext
import requests
import json
import pandas as pd


client_id = "a301********-98fe1dcde27e"  # application id
resource_uri = "https://analysis.windows.net/powerbi/api"  
user_name = "d*@microsoft.com"
user_password = "****"

auth_context = AuthenticationContext("https://login.microsoftonline.com/&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;Your_tenant_name&lt;/STRONG&gt;&lt;/FONT&gt;")
token_response = auth_context.acquire_token_with_username_password(resource_uri, user_name, user_password, client_id)
token = "Bearer " + token_response["accessToken"]

api_url = "https://api.powerbi.com/v1.0/myorg/admin/groups"
headers = {"Authorization": token}
r = requests.get(api_url, headers = headers)

result = pd.io.json.json_normalize(json.loads(r.text)["value"])&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://ibb.co/SB30328" target="_blank"&gt;&lt;IMG src="https://ip1.i.lithium.com/436e18878d8044a86969b1a99512f7d729cc4bc1/68747470733a2f2f692e6962622e636f2f4752356b35584c2f506f7765722d42492d415049322e706e67" border="0" alt="Power-BI-API2" /&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 09:52:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-API/m-p/605024#M18286</guid>
      <dc:creator>v-jiascu-msft</dc:creator>
      <dc:date>2019-01-21T09:52:17Z</dc:date>
    </item>
  </channel>
</rss>

