<?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: Access Power BI API with Python in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/190087#M6029</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/32269"&gt;@jb007&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;My requirement is to push real time data into Power BI using Python to first read from a database and then send the data inside a Streaming dataset in Power BI.&lt;/P&gt;
&lt;P&gt;The first thing I want is to make a simple "get" call to Power BI.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;The &lt;A href="https://docs.microsoft.com/en-gb/azure/active-directory/develop/active-directory-protocols-oauth-code#oauth-20-authorization-flow" target="_blank" rel="nofollow noreferrer"&gt;official documentation&lt;/A&gt; explains the processes of connecting to Power BI via the REST API for either a Client App or a Web App. However, I'm using Python - not sure if that is either a client app or a &lt;FONT size="5"&gt;&lt;STRONG&gt;web app&lt;/STRONG&gt;&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Anyway, I am able to get the accessToken using the adal library and the method &lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-python/blob/dev/sample/client_credentials_sample.py" target="_blank" rel="nofollow noreferrer"&gt;.acquire_token_with_client_credentials&lt;/A&gt;, which asks for authority_uri, tenant, &lt;FONT size="5"&gt;&lt;STRONG&gt;client_id&lt;/STRONG&gt;&lt;/FONT&gt; and &lt;FONT size="5"&gt;&lt;STRONG&gt;client_secret&lt;/STRONG&gt; &lt;/FONT&gt;(notice this is not asking for username and password). By the way, I've also tried getting the accessToken with &lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-python/blob/dev/sample/refresh_token_sample.py" target="_blank" rel="nofollow noreferrer"&gt;.acquire_token_with_username_password&lt;/A&gt;, but that didn't work.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Unfortunately, when I use the below code with the obtained accessToken, I get a response 403.&lt;/P&gt;
&lt;PRE&gt;#accessToken is received using the adal libary 
headers = {'Authorization': 'Bearer ' + accessToken, 'Content-Type': 'application/json'}
read_datasets = requests.get('https://api.powerbi.com/v1.0/myorg/datasets', headers=headers)
#shockingly, this will result in a response 403&lt;/PRE&gt;
&lt;P&gt;After reading other stackoverflow posts and looking at console apps, I believe the reason this doesn't work is because there is no user sign-in process.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/32341877/cant-get-client-credentials-access-token-to-authorize-power-bi?rq=1" target="_blank"&gt;This thread&lt;/A&gt; mentions that using Client Credentials is not enough (it is enough to get the accessToken, but not enough to use the APIs)&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Not sure how to proceed, but what I need is perhaps a way to keep using this &lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-python/blob/dev/sample/client_credentials_sample.py" target="_blank" rel="nofollow noreferrer"&gt;adal template&lt;/A&gt; that gives me the accessToken, and also to provide my username and password (in a silent way, i.e. via the scrip, without GUI), and together with the accessToken, to access the APIs.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/32269"&gt;@jb007&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;It is a web app. After registion, Use the client_id and client_secrect to get the accesstoken. What are the client_id and client_secrect in your case? 403 in your case most probably indicates a invalid accesstoken, when dedcoding the token at &lt;STRONG&gt;&lt;A href="http://jwt.io" target="_blank"&gt;http://jwt.io&lt;/A&gt;&lt;/STRONG&gt;, what is the scp(scope)? Normally you'd get access as below according to the premission checked when registering the app.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 549px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/44707i214C5C41699EA078/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Techinically it is possible to get the access token without GUI interaction in a silent way,&amp;nbsp;just call the POST API with grant_type=password. Then use the refreshtoken to get token afterwards. &lt;STRONG&gt;Note that it might violate the license compliance&lt;/STRONG&gt; if other people use the this token to access the embedded reports. People who access the reports in Power BI service shall have their own accounts/tokens.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/44708i39E7303E5DF22006/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/44710iE76E507A576D2435/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However for the first time, AFAIK, you'll always have the GUI consent&amp;nbsp;page and accept&amp;nbsp;it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="large.png" style="width: 600px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/44711i31D645676B25EDEC/image-size/large?v=v2&amp;amp;px=999" role="button" title="large.png" alt="large.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Jun 2017 01:39:35 GMT</pubDate>
    <dc:creator>Eric_Zhang</dc:creator>
    <dc:date>2017-06-08T01:39:35Z</dc:date>
    <item>
      <title>Access Power BI API with Python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/189165#M6015</link>
      <description>&lt;P&gt;My requirement is to push real time data into Power BI using Python to first read from a database and then send the data inside a Streaming dataset in Power BI.&lt;/P&gt;&lt;P&gt;The first thing I want is to make a simple "get" call to Power BI.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;The &lt;A href="https://docs.microsoft.com/en-gb/azure/active-directory/develop/active-directory-protocols-oauth-code#oauth-20-authorization-flow" target="_blank" rel="nofollow noreferrer"&gt;official documentation&lt;/A&gt; explains the processes of connecting to Power BI via the REST API for either a Client App or a Web App. However, I'm using Python - not sure if that is either a client app or a web app.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Anyway, I am able to get the accessToken using the adal library and the method &lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-python/blob/dev/sample/client_credentials_sample.py" target="_blank" rel="nofollow noreferrer"&gt;.acquire_token_with_client_credentials&lt;/A&gt;, which asks for authority_uri, tenant, client_id and client_secret (notice this is not asking for username and password). By the way, I've also tried getting the accessToken with &lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-python/blob/dev/sample/refresh_token_sample.py" target="_blank" rel="nofollow noreferrer"&gt;.acquire_token_with_username_password&lt;/A&gt;, but that didn't work.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Unfortunately, when I use the below code with the obtained accessToken, I get a response 403.&lt;/P&gt;&lt;PRE&gt;#accessToken is received using the adal libary 
headers = {'Authorization': 'Bearer ' + accessToken, 'Content-Type': 'application/json'}
read_datasets = requests.get('https://api.powerbi.com/v1.0/myorg/datasets', headers=headers)
#shockingly, this will result in a response 403&lt;/PRE&gt;&lt;P&gt;After reading other stackoverflow posts and looking at console apps, I believe the reason this doesn't work is because there is no user sign-in process.&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/32341877/cant-get-client-credentials-access-token-to-authorize-power-bi?rq=1" target="_blank"&gt;This thread&lt;/A&gt; mentions that using Client Credentials is not enough (it is enough to get the accessToken, but not enough to use the APIs)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Not sure how to proceed, but what I need is perhaps a way to keep using this &lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-python/blob/dev/sample/client_credentials_sample.py" target="_blank" rel="nofollow noreferrer"&gt;adal template&lt;/A&gt; that gives me the accessToken, and also to provide my username and password (in a silent way, i.e. via the scrip, without GUI), and together with the accessToken, to access the APIs.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2017 19:17:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/189165#M6015</guid>
      <dc:creator>jb007</dc:creator>
      <dc:date>2017-06-06T19:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: Access Power BI API with Python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/190087#M6029</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/32269"&gt;@jb007&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;My requirement is to push real time data into Power BI using Python to first read from a database and then send the data inside a Streaming dataset in Power BI.&lt;/P&gt;
&lt;P&gt;The first thing I want is to make a simple "get" call to Power BI.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;The &lt;A href="https://docs.microsoft.com/en-gb/azure/active-directory/develop/active-directory-protocols-oauth-code#oauth-20-authorization-flow" target="_blank" rel="nofollow noreferrer"&gt;official documentation&lt;/A&gt; explains the processes of connecting to Power BI via the REST API for either a Client App or a Web App. However, I'm using Python - not sure if that is either a client app or a &lt;FONT size="5"&gt;&lt;STRONG&gt;web app&lt;/STRONG&gt;&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Anyway, I am able to get the accessToken using the adal library and the method &lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-python/blob/dev/sample/client_credentials_sample.py" target="_blank" rel="nofollow noreferrer"&gt;.acquire_token_with_client_credentials&lt;/A&gt;, which asks for authority_uri, tenant, &lt;FONT size="5"&gt;&lt;STRONG&gt;client_id&lt;/STRONG&gt;&lt;/FONT&gt; and &lt;FONT size="5"&gt;&lt;STRONG&gt;client_secret&lt;/STRONG&gt; &lt;/FONT&gt;(notice this is not asking for username and password). By the way, I've also tried getting the accessToken with &lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-python/blob/dev/sample/refresh_token_sample.py" target="_blank" rel="nofollow noreferrer"&gt;.acquire_token_with_username_password&lt;/A&gt;, but that didn't work.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Unfortunately, when I use the below code with the obtained accessToken, I get a response 403.&lt;/P&gt;
&lt;PRE&gt;#accessToken is received using the adal libary 
headers = {'Authorization': 'Bearer ' + accessToken, 'Content-Type': 'application/json'}
read_datasets = requests.get('https://api.powerbi.com/v1.0/myorg/datasets', headers=headers)
#shockingly, this will result in a response 403&lt;/PRE&gt;
&lt;P&gt;After reading other stackoverflow posts and looking at console apps, I believe the reason this doesn't work is because there is no user sign-in process.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/32341877/cant-get-client-credentials-access-token-to-authorize-power-bi?rq=1" target="_blank"&gt;This thread&lt;/A&gt; mentions that using Client Credentials is not enough (it is enough to get the accessToken, but not enough to use the APIs)&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Not sure how to proceed, but what I need is perhaps a way to keep using this &lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-python/blob/dev/sample/client_credentials_sample.py" target="_blank" rel="nofollow noreferrer"&gt;adal template&lt;/A&gt; that gives me the accessToken, and also to provide my username and password (in a silent way, i.e. via the scrip, without GUI), and together with the accessToken, to access the APIs.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/32269"&gt;@jb007&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;It is a web app. After registion, Use the client_id and client_secrect to get the accesstoken. What are the client_id and client_secrect in your case? 403 in your case most probably indicates a invalid accesstoken, when dedcoding the token at &lt;STRONG&gt;&lt;A href="http://jwt.io" target="_blank"&gt;http://jwt.io&lt;/A&gt;&lt;/STRONG&gt;, what is the scp(scope)? Normally you'd get access as below according to the premission checked when registering the app.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 549px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/44707i214C5C41699EA078/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Techinically it is possible to get the access token without GUI interaction in a silent way,&amp;nbsp;just call the POST API with grant_type=password. Then use the refreshtoken to get token afterwards. &lt;STRONG&gt;Note that it might violate the license compliance&lt;/STRONG&gt; if other people use the this token to access the embedded reports. People who access the reports in Power BI service shall have their own accounts/tokens.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/44708i39E7303E5DF22006/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/44710iE76E507A576D2435/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However for the first time, AFAIK, you'll always have the GUI consent&amp;nbsp;page and accept&amp;nbsp;it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="large.png" style="width: 600px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/44711i31D645676B25EDEC/image-size/large?v=v2&amp;amp;px=999" role="button" title="large.png" alt="large.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 01:39:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/190087#M6029</guid>
      <dc:creator>Eric_Zhang</dc:creator>
      <dc:date>2017-06-08T01:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Access Power BI API with Python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/312578#M9230</link>
      <description>&lt;P&gt;HI , I am facing the same issue .&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using to python script to use powerbi rest api.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) First I regestered an app as a web app and noted its app id (to be used as client id)&lt;/P&gt;&lt;P&gt;2) I created a secret key for it&lt;/P&gt;&lt;P&gt;3) Gave it the required permissions&lt;/P&gt;&lt;P&gt;4) using the ADAL module , I was able to get the access token&lt;/P&gt;&lt;P&gt;5)But when I use the token in further get requests , I get the "403 : Forbidden" error , usually meaning that unauthorised access&lt;/P&gt;&lt;P&gt;Please help!!!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 11:13:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/312578#M9230</guid>
      <dc:creator>kartikg2jee</dc:creator>
      <dc:date>2017-11-28T11:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: Access Power BI API with Python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/312579#M9231</link>
      <description>&lt;PRE&gt;def sample_query():
    print("--------------inside sample query-----------------")
    
    headersData = { 'Authorization': 'Bearer'+tokenString ,
    'Content-Type': 'application/json',
     'User-Agent': "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36" }
    #urllib.request.urlopen
    
    request = urllib.request.Request('https://api.powerbi.com/v1.0/myorg/groups',headers=headersData)
    print("________________________________")
    print(request.get_full_url())
    print("________________________________")
    response_body = urllib.request.urlopen(request)
    
    print(response_body)&lt;/PRE&gt;&lt;P&gt;here is the query code after I get the auth tokken&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 11:15:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/312579#M9231</guid>
      <dc:creator>kartikg2jee</dc:creator>
      <dc:date>2017-11-28T11:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: Access Power BI API with Python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/312794#M9246</link>
      <description>&lt;P&gt;This works for me.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Reporting Class: Using single user access with app owns data&lt;/P&gt;&lt;PRE&gt;class EmbedToken:
    def __init__(self, report_id, group_id, settings=None):
        self.username = 'USER'
        self.password = 'PASSWORD'
        self.client_id = 'CLIENT ID'
        self.report_id = report_id
        self.group_id = group_id
        if settings is None:
            self.settings = {'accessLevel': 'View', 'allowSaveAs': 'false'}
        else:
            self.settings = settings
        self.access_token = self.get_access_token()
        self.config = self.get_embed_token()

    def get_access_token(self):
        data = {
            'grant_type': 'password',
            'scope': 'openid',
            'resource': r'https://analysis.windows.net/powerbi/api',
            'client_id': self.client_id,
            'username': self.username,
            'password': self.password
        }
        response = requests.post('https://login.microsoftonline.com/common/oauth2/token', data=data)
        return response.json().get('access_token')

    def get_embed_token(self):
        dest = 'https://api.powerbi.com/v1.0/myorg/groups/' + self.group_id \
               + '/reports/' + self.report_id + '/GenerateToken'
        embed_url = 'https://app.powerbi.com/reportEmbed?reportId=' \
                    + self.report_id + '&amp;amp;groupId=' + self.group_id
        headers = {'Authorization': 'Bearer ' + self.access_token}
        response = requests.post(dest, data=self.settings, headers=headers)
        self.token = response.json().get('token')
        return {'token': self.token, 'embed_url': embed_url, 'report_id': self.report_id}

    def get_report(self):
        headers = {'Authorization': 'Bearer ' + self.token}
        dest = 'https://app.powerbi.com/reportEmbed?reportId=' + self.report_id + \
               '&amp;amp;amp;groupId=' + self.group_id
        response = requests.get(dest, data=self.settings, headers=headers)
        return response&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Django View&lt;/P&gt;&lt;PRE&gt;def index(request):
... irrelevant Code...
    conf = EmbedToken(report.get('report_id'), report.get('group_id'))
    token = conf.get_embed_token()
    return render(request, 'unfi_breakout/unfi_breakout.html', {'selectedReport': token.get('report_id'),
                                                                'embedToken': token.get('token')})&lt;/PRE&gt;&lt;P&gt;HTML&lt;/P&gt;&lt;PRE&gt;{% extends extension %}
{% load staticfiles %}
{% block main %}

&amp;lt;div id="reportContainer" style="height: 100% "&amp;gt;
    &amp;lt;script src="{% static 'PowerBi/dist/powerbi.js' %}"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script&amp;gt;
    var models = window['powerbi-client'].models;

    var embedConfiguration = {
        type: 'report',
        id: '{{ selectedReport }}',
        embedUrl: 'https://app.powerbi.com/reportEmbed',
        tokenType: models.TokenType.Embed,
        accessToken: '{{ embedToken }}',
        settings: {
              filterPaneEnabled: false
            }
    };

    var element = document.getElementById('reportContainer');
    var report = powerbi.embed(element, embedConfiguration);
    &amp;lt;/script&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;

{% endblock %}&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Nov 2017 17:53:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/312794#M9246</guid>
      <dc:creator>adamwallace3</dc:creator>
      <dc:date>2017-11-28T17:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Access Power BI API with Python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/394305#M11746</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;BR /&gt;I want to reproduce this part on C# to manage row level security with python code.&lt;BR /&gt;Any help ?&lt;/P&gt;&lt;PRE&gt;GenerateTokenRequest generateTokenRequestParameters;
                    // This is how you create embed token with effective identities
                    if (!string.IsNullOrEmpty(username))
                    {
                        var rls = new EffectiveIdentity(username, new List&amp;lt;string&amp;gt; { report.DatasetId });
                        if (!string.IsNullOrWhiteSpace(roles))
                        {
                            var rolesList = new List&amp;lt;string&amp;gt;();
                            rolesList.AddRange(roles.Split(','));
                            rls.Roles = rolesList;
                        }
                        // Generate Embed Token with effective identities.
                        generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view", identities: new List&amp;lt;EffectiveIdentity&amp;gt; { rls });
                    }
                    else
                    {
                        // Generate Embed Token for reports without effective identities.
                        generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view");
                    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2018 13:02:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/394305#M11746</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-04-13T13:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: Access Power BI API with Python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/409726#M12210</link>
      <description>&lt;P&gt;This might be helpful for anyone visiting;&amp;nbsp;I have started working on a python client for the PowerBI API, feel free to use it!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/cmberryau/pypowerbi" target="_blank"&gt;https://github.com/cmberryau/pypowerbi&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now I have added the functionality I require, but I'll be continuing to develop it as I'm now working full time on a python back-end project using PowerBI.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far, ive added the functionality to:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Use a standard ADAL token for authentication&lt;/P&gt;&lt;P&gt;- Pull reports&lt;/P&gt;&lt;P&gt;- Clone reports&lt;/P&gt;&lt;P&gt;- Delete reports&lt;/P&gt;&lt;P&gt;- Rebind reports&lt;/P&gt;&lt;P&gt;- Embed reports&lt;/P&gt;&lt;P&gt;- Pull datasets&lt;/P&gt;&lt;P&gt;- Push datasets&lt;/P&gt;&lt;P&gt;- Delete datasets&lt;/P&gt;&lt;P&gt;- Push rows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 08:39:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/409726#M12210</guid>
      <dc:creator>zotai</dc:creator>
      <dc:date>2018-05-03T08:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: Access Power BI API with Python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/640872#M18763</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/6971"&gt;@Eric_Zhang&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please give a code example on this part?: &lt;EM&gt;"Techinically it is possible to get the access token without GUI interaction in a silent way, just call the POST API with grant_type=password. Then use the refreshtoken to get token afterwards."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am close to desperation here. My code is below and the token request returns this:&lt;/P&gt;&lt;PRE&gt;Get Token request returned http error: 400 and server response: {"error":"invalid_grant","error_description":"AADSTS65001:&lt;BR /&gt; The user or administrator has not consented to use the application with ID '6d6c4a8d-3560-4e8f-b705-116bc57d7b99' named 'PBI_API'.&lt;BR /&gt; Send an interactive authorization request for this user and resource.\r\nTrace ID: b2d3934d-196f-43d5-ab43-a59a31c01500\r\nCorrelation ID:&lt;BR /&gt; e124c31f-91c6-4c00-8ab8-38dcbeb91ab2\r\nTimestamp: 2019-03-09 05:39:46Z","error_codes":[65001],"timestamp"&lt;BR /&gt;:"2019-03-09 05:39:46Z","trace_id":"b2d3934d-196f-43d5-ab43-a59a31c01500","correlation_id":"e124c31f-91c6-4c00-8ab8-38dcbeb91ab2",&lt;BR /&gt;"suberror":"consent_required"}&lt;/PRE&gt;&lt;P&gt;First, I tried get_token_with_credentials which was successful however I could not send any requests with this token as it provides insufficient access, the issue was discussed here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/32341877/cant-get-client-credentials-access-token-to-authorize-power-bi?rq=1" target="_self"&gt;https://stackoverflow.com/questions/32341877/cant-get-client-credentials-access-token-to-authorize-power-bi?rq=1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so in request_token.py in site_packages/adal folder I added the below (a colleague of mine said it worked for him) :&lt;/P&gt;&lt;PRE&gt;oauth_parameters[OAUTH2_PARAMETERS.CLIENT_SECRET] = "hardcoded_clientSecret"&lt;/PRE&gt;&lt;P&gt;to the following functions:&lt;/P&gt;&lt;PRE&gt;def _get_token_username_password_managed(self, username, password):
def _perform_wstrust_assertion_oauth_exchange(self, wstrust_response):&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;import adal
import requests

parmeters = {
"resource": "https://analysis.windows.net/powerbi/api",
"tenant" : "xxxxx.onmicrosoft.com",
"authorityHostUrl" : "https://login.windows.net",
"clientId" : "6d6c4a8d-3560-4e8f-b705-116bc57d7b99",
"clientSecret" : "xxxxxxxxxx",
"username" : "xxxxxxxx@xxxxxx.com"
}

authority_url = (parmeters['authorityHostUrl'] + '/' +
parmeters['tenant'])
GRAPH_RESOURCE = '00000002-0000-0000-c000-000000000000'
RESOURCE = parmeters.get('resource', GRAPH_RESOURCE)

context = adal.AuthenticationContext(
authority_url, validate_authority=True,
)
token = context.acquire_token_with_username_password(RESOURCE,
parmeters['username'],'my_password',parmeters['clientId'])

accessToken = token['accessToken']&lt;/PRE&gt;&lt;P&gt;the task I am trying to achieve is to push dataset refreshes once underlying data is updated, but so far I couldn't properly authincate:&lt;/P&gt;&lt;PRE&gt;headers = {'Authorization': 'Bearer ' + accessToken, 'Content-Type': 'application/json'}
requests.post(f'https://api.powerbi.com/v1.0/myorg/groups/{group_id}/datasets/{dataset_id}/refreshes',headers = headers)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Mar 2019 06:50:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/640872#M18763</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-03-09T06:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: Access Power BI API with Python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/641129#M18766</link>
      <description>&lt;P&gt;Ok, I am now able to answer this myself. What I needed to do is to go to App Registration in AD and press Grant permissions.&lt;/P&gt;&lt;P&gt;Was quite surprised nobody else had this issue.&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2019-03-10 at 3.29.44 pm.png" style="width: 600px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/151383iE76E1634D76D225B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2019-03-10 at 3.29.44 pm.png" alt="Screen Shot 2019-03-10 at 3.29.44 pm.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Mar 2019 04:56:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/641129#M18766</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-03-10T04:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: Access Power BI API with Python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/843870#M21359</link>
      <description>&lt;P&gt;Hi, I really like the look of this.&amp;nbsp; Does it enable you to copy a dataset from one workspace to another?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Ricky&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2019 16:04:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/843870#M21359</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-12T16:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: Access Power BI API with Python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/961508#M22606</link>
      <description>&lt;P&gt;In this code view.py EmbedToken(report.get() is not defined ??? what is the report attribute in class.please reply thank in advance&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2020 05:35:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Access-Power-BI-API-with-Python/m-p/961508#M22606</guid>
      <dc:creator>hprasanth</dc:creator>
      <dc:date>2020-03-06T05:35:18Z</dc:date>
    </item>
  </channel>
</rss>

