<?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 token power bi python in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/access-token-power-bi-python/m-p/351579#M10459</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/53438"&gt;@oflok000&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;SPAN&gt;And to add to that post, everything about authentication using .NET should work just as well with the equivalent Python library&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;adal&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;-&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-python" target="_blank"&gt;https://github.com/AzureAD/azure-activedirectory-library-for-python&lt;/A&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;According to &lt;A href="https://github.com/Microsoft/PTVS/issues/809" target="_self"&gt;this&lt;/A&gt; similar thread, you should be able to use the &lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-python" target="_self"&gt;Python library adal&lt;/A&gt; to get the access token with Power BI Rest API. The sample code below is for your reference. &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://community.fabric.microsoft.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;
&lt;PRE&gt;import adal

authority_url = 'https://login.microsoftonline.com/testcompany.onmicrosoft.com'
context = adal.AuthenticationContext(
    authority_url,
    validate_authority=True,
    api_version=None
)

token = context.acquire_token_with_username_password(
    resource='https://analysis.windows.net/powerbi/api',
    username='john.doe@testcompany.onmicrosoft.com',
    password='secret',
    client_id='22a6fc5a-46fe-4f85-8168-281ece441742'
)

access_token = token['accessToken']&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
    <pubDate>Mon, 05 Feb 2018 08:41:02 GMT</pubDate>
    <dc:creator>v-ljerr-msft</dc:creator>
    <dc:date>2018-02-05T08:41:02Z</dc:date>
    <item>
      <title>access token power bi python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/access-token-power-bi-python/m-p/350405#M10400</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I wrote code using sample on python. All the time I have 400 Bad request. Where can be problem?&lt;/P&gt;&lt;PRE&gt;import urllib
import json
import requests

url = 'https://login.microsoftonline.com/common/oauth2/token'
data = {
    'grant_type':'password',
    'scope':'openid',
    'resource':'https://analysis.windows.net/powerbi/api',
    'client_id':'here id',
    'client_secret': 'here secret',
    'username':'here username',
    'password':'here password'
       }
response = requests.post(url,data=data)
#print(data)
print(response);&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Feb 2018 07:39:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/access-token-power-bi-python/m-p/350405#M10400</guid>
      <dc:creator>oflok000</dc:creator>
      <dc:date>2018-02-02T07:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: access token power bi python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/access-token-power-bi-python/m-p/351579#M10459</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/53438"&gt;@oflok000&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;SPAN&gt;And to add to that post, everything about authentication using .NET should work just as well with the equivalent Python library&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;adal&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;-&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-python" target="_blank"&gt;https://github.com/AzureAD/azure-activedirectory-library-for-python&lt;/A&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;According to &lt;A href="https://github.com/Microsoft/PTVS/issues/809" target="_self"&gt;this&lt;/A&gt; similar thread, you should be able to use the &lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-python" target="_self"&gt;Python library adal&lt;/A&gt; to get the access token with Power BI Rest API. The sample code below is for your reference. &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://community.fabric.microsoft.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;
&lt;PRE&gt;import adal

authority_url = 'https://login.microsoftonline.com/testcompany.onmicrosoft.com'
context = adal.AuthenticationContext(
    authority_url,
    validate_authority=True,
    api_version=None
)

token = context.acquire_token_with_username_password(
    resource='https://analysis.windows.net/powerbi/api',
    username='john.doe@testcompany.onmicrosoft.com',
    password='secret',
    client_id='22a6fc5a-46fe-4f85-8168-281ece441742'
)

access_token = token['accessToken']&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 08:41:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/access-token-power-bi-python/m-p/351579#M10459</guid>
      <dc:creator>v-ljerr-msft</dc:creator>
      <dc:date>2018-02-05T08:41:02Z</dc:date>
    </item>
  </channel>
</rss>

