<?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 401 error code only when trying to Export a report in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/401-error-code-only-when-trying-to-Export-a-report/m-p/1689632#M28090</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can get an access token using oauth, with my client_id and my master user/password.&amp;nbsp; &amp;nbsp;Using that token I can use it&amp;nbsp; to get a list of all my respots using&amp;nbsp; the entrypoint&amp;nbsp; groups ("&lt;A href="https://api.powerbi.com/v1.0/myorg/groups" target="_blank"&gt;https://api.powerbi.com/v1.0/myorg/groups&lt;/A&gt;").&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I get a 401 error code if I try to use the same token (or even acquire a brand new one) to access this other entrypoint:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;A href="https://community.fabric.microsoft.com/" target="_blank"&gt;https://api.powerbi.com/v1.0/myorg/reports/&amp;lt;report_id&amp;gt;/Export&lt;/A&gt;&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;My application has already these permissions granted:&amp;nbsp; Report.Read.All.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I know that the issue is the token, because I can get a valid token using "Connect-PowerBIServiceAccount&amp;nbsp; &amp;nbsp;and entering the master user credentials, then I get the token by issuing a Get-PowerBIAccessToken -AsString and use it on my script.&amp;nbsp; Then I am able to export the report with no issues.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Please, give me some idea of what I am missing here.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you very much,&lt;/DIV&gt;&lt;DIV&gt;Andres&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Feb 2021 12:33:27 GMT</pubDate>
    <dc:creator>misterwalrus</dc:creator>
    <dc:date>2021-02-25T12:33:27Z</dc:date>
    <item>
      <title>401 error code only when trying to Export a report</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/401-error-code-only-when-trying-to-Export-a-report/m-p/1689632#M28090</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can get an access token using oauth, with my client_id and my master user/password.&amp;nbsp; &amp;nbsp;Using that token I can use it&amp;nbsp; to get a list of all my respots using&amp;nbsp; the entrypoint&amp;nbsp; groups ("&lt;A href="https://api.powerbi.com/v1.0/myorg/groups" target="_blank"&gt;https://api.powerbi.com/v1.0/myorg/groups&lt;/A&gt;").&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I get a 401 error code if I try to use the same token (or even acquire a brand new one) to access this other entrypoint:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;A href="https://community.fabric.microsoft.com/" target="_blank"&gt;https://api.powerbi.com/v1.0/myorg/reports/&amp;lt;report_id&amp;gt;/Export&lt;/A&gt;&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;My application has already these permissions granted:&amp;nbsp; Report.Read.All.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I know that the issue is the token, because I can get a valid token using "Connect-PowerBIServiceAccount&amp;nbsp; &amp;nbsp;and entering the master user credentials, then I get the token by issuing a Get-PowerBIAccessToken -AsString and use it on my script.&amp;nbsp; Then I am able to export the report with no issues.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Please, give me some idea of what I am missing here.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you very much,&lt;/DIV&gt;&lt;DIV&gt;Andres&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 12:33:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/401-error-code-only-when-trying-to-Export-a-report/m-p/1689632#M28090</guid>
      <dc:creator>misterwalrus</dc:creator>
      <dc:date>2021-02-25T12:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: 401 error code only when trying to Export a report</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/401-error-code-only-when-trying-to-Export-a-report/m-p/1689669#M28091</link>
      <description>&lt;P&gt;This is very interesting, someone in StackOverflow recommended me to paste the token I got from my script into jwt.io and look at the scp field (scope). It happens that the 'bad' token has the correct scopes,&amp;nbsp; the 'good' token, the one I got when connecting to powerbi by Connect-PowerBIServiceAccount and use my username/password&amp;nbsp; &amp;nbsp;has a different scope (user_impersonation)&amp;nbsp; and a different appid.&lt;/P&gt;&lt;P&gt;I took the appid of the good token and now I am using it, instead of the original application id. It works flawlessly from the python script now.&lt;/P&gt;&lt;P&gt;I suppose this is not the correct solution, and indeed, not the one I was expecting for.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is happening to the 'bad' application id? I don't understand it , specially,when the token shows all the correct permissions:&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is from jwt.io:&amp;nbsp;&lt;/P&gt;&lt;P&gt;"scp": "App.Read.All Capacity.Read.All Dashboard.Read.All Dataflow.Read.All Dataset.Read.All Gateway.Read.All Report.Read.All StorageAccount.Read.All Tenant.Read.All Workspace.Read.All",&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 18:47:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/401-error-code-only-when-trying-to-Export-a-report/m-p/1689669#M28091</guid>
      <dc:creator>misterwalrus</dc:creator>
      <dc:date>2021-02-25T18:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: 401 error code only when trying to Export a report</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/401-error-code-only-when-trying-to-Export-a-report/m-p/1710608#M28274</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/287262"&gt;@misterwalrus&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The 401 error means that there is no access permission. I guess it should be a permission problem.&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>Tue, 09 Mar 2021 06:43:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/401-error-code-only-when-trying-to-Export-a-report/m-p/1710608#M28274</guid>
      <dc:creator>v-lionel-msft</dc:creator>
      <dc:date>2021-03-09T06:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: 401 error code only when trying to Export a report</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/401-error-code-only-when-trying-to-Export-a-report/m-p/1712022#M28284</link>
      <description>&lt;P&gt;Soution:&amp;nbsp; &amp;nbsp;I was using the endpoint:&amp;nbsp;&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Developer/401-error-code-only-when-trying-to-Export-a-report/m-p/1710608" target="_blank" rel="nofollow noopener noreferrer"&gt;https://api.powerbi.com/v1.0/myorg/reports/&amp;lt;report_id&amp;gt;/Export&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;That endpoint works perfectly with the master password, becuase it refers to my workspace.&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But when using a service principal, you don't have a "My workspace"&amp;nbsp; to export from.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If the endpoint used change to '&lt;A href="https://community.fabric.microsoft.com/" target="_blank"&gt;https://api.powerbi.com/v1.0/myorg/groups/&amp;lt;group_id&amp;gt;/reports'&amp;nbsp;&lt;/A&gt; then there is no 401 error anymore.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 16:34:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/401-error-code-only-when-trying-to-Export-a-report/m-p/1712022#M28284</guid>
      <dc:creator>misterwalrus</dc:creator>
      <dc:date>2021-03-09T16:34:19Z</dc:date>
    </item>
  </channel>
</rss>

