<?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: Operation returned an invalid status code 'Unauthorized'' in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Unauthorized/m-p/2428411#M35252</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/372180"&gt;@WilliamTit&lt;/a&gt;&amp;nbsp;，&lt;/P&gt;
&lt;P&gt;If you are using service principal authentication, please check whether you have enabled "&lt;A href="https://docs.microsoft.com/en-us/power-bi/admin/service-admin-portal-admin-api-settings#allow-service-principals-to-use-read-only-power-bi-admin-apis" target="_self"&gt;&lt;STRONG&gt;Allow service principals to use Power BI APIs&lt;/STRONG&gt;&lt;/A&gt;" feature in &lt;STRONG&gt;Admin portal&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yingyinr_0-1648696968257.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/692554i363DE37E0192265E/image-size/large?v=v2&amp;amp;px=999" role="button" title="yingyinr_0-1648696968257.png" alt="yingyinr_0-1648696968257.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Also, has&amp;nbsp;the service principal been added as member or admin of workspace?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yingyinr_1-1648697072726.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/692555i0B2088C2F4976796/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yingyinr_1-1648697072726.png" alt="yingyinr_1-1648697072726.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And you can refer the following video to check if something is missing...&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=271LkXJ8niM" target="_self"&gt;Embed Power BI Report for Customers using App Own Concept and Service Principal&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=z6kFtJVhgjQ" target="_self"&gt;Embed Power BI Report for Customers using App Owns Data and Master User&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In addition, the followings are the ones which has similar problem with yours. Hope they can help you.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/49037233/operation-returned-an-invalid-status-code-unauthorized" target="_self"&gt;Operation returned an invalid status code 'Unauthorized''&lt;/A&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;&lt;SPAN&gt;Based on your description, I assumed that you are using the Access token for Power BI users (user owns data) approach. I would recommend you use&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A style="font-family: inherit; background-color: #ffffff;" href="https://jwt.io/" rel="nofollow noreferrer" target="_blank"&gt;https://jwt.io/&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;to decode the access_token after successfully invoked&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;authContext.AcquireTokenAsync&lt;/CODE&gt;&lt;SPAN&gt;. Make sure the&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;aud&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;is&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;&lt;A href="https://analysis.windows.net/powerbi/api" target="_blank"&gt;https://analysis.windows.net/powerbi/api&lt;/A&gt;&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;and check the permissions scope property&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;scp&lt;/CODE&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;For&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://msdn.microsoft.com/en-us/library/mt243842.aspx" rel="nofollow noreferrer" target="_blank"&gt;Get Groups&lt;/A&gt;, the required scope would look as follows:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Required scope&lt;/STRONG&gt;: Group.Read.All or Group.ReadWrite.All or Workspace.Read.All or Workspace.ReadWrite.All&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You could also use fiddler or postman to simulate the request against the get groups endpoint with the access_token received in your WPF application to narrow down this issue.&lt;/P&gt;
&lt;P&gt;Moreover, you could follow&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/register-app" rel="nofollow noreferrer" target="_blank"&gt;Register an application&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to check your Azure AD app and make sure the required delegated permissions to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Power BI Service (Microsoft.Azure.AnalysisServices)&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;API have been correctly configured.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Developer/401-when-accessing-any-Power-BI-API-endpoints/m-p/336493#M9954" target="_self"&gt;401 when accessing any Power BI API endpoints&lt;/A&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;SPAN&gt;I found something that work and documented it (with code) here:&amp;nbsp;&lt;/SPAN&gt;&lt;A style="font-family: inherit; font-size: 16px; background-color: #ffffff;" href="https://bitbucket.org/omnistream/powerbi-api-example" target="_blank" rel="nofollow noopener noreferrer"&gt;https://bitbucket.org/omnistream/powerbi-api-example&lt;/A&gt;
&lt;P&gt;Hopefully it would help other people in need!&lt;/P&gt;
&lt;P&gt;It's not entirely satisfying: I'm notably not too sure why I should use this authentication endpoint instead of the one I found in other documentation, nor why I have to use a username/password on top of the app credentials, especially since it's not a super secure way to do it; I'm concerned it may get deprecated in the future. But it works.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
    <pubDate>Thu, 31 Mar 2022 03:29:50 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-03-31T03:29:50Z</dc:date>
    <item>
      <title>Operation returned an invalid status code 'Unauthorized''</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Unauthorized/m-p/2421264#M35198</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to run sample report&amp;nbsp;&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/embedded/embed-sample-for-customers?tabs=net-core" target="_blank" rel="noopener"&gt;https://docs.microsoft.com/en-us/power-bi/developer/embedded/embed-sample-for-customers?tabs=net-core&lt;/A&gt;&amp;nbsp; and getting error "Operation returned an invalid status code 'Unauthorized''" at&amp;nbsp;&lt;EM&gt;var pbiReport = pbiClient.Reports.GetReportInGroup(workspaceId, reportId);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I gave the user account admin right to the workspace, report and dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone please help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;William.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 10:47:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Unauthorized/m-p/2421264#M35198</guid>
      <dc:creator>WilliamTit</dc:creator>
      <dc:date>2022-03-28T10:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Operation returned an invalid status code 'Unauthorized''</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Unauthorized/m-p/2428411#M35252</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/372180"&gt;@WilliamTit&lt;/a&gt;&amp;nbsp;，&lt;/P&gt;
&lt;P&gt;If you are using service principal authentication, please check whether you have enabled "&lt;A href="https://docs.microsoft.com/en-us/power-bi/admin/service-admin-portal-admin-api-settings#allow-service-principals-to-use-read-only-power-bi-admin-apis" target="_self"&gt;&lt;STRONG&gt;Allow service principals to use Power BI APIs&lt;/STRONG&gt;&lt;/A&gt;" feature in &lt;STRONG&gt;Admin portal&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yingyinr_0-1648696968257.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/692554i363DE37E0192265E/image-size/large?v=v2&amp;amp;px=999" role="button" title="yingyinr_0-1648696968257.png" alt="yingyinr_0-1648696968257.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Also, has&amp;nbsp;the service principal been added as member or admin of workspace?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yingyinr_1-1648697072726.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/692555i0B2088C2F4976796/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yingyinr_1-1648697072726.png" alt="yingyinr_1-1648697072726.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And you can refer the following video to check if something is missing...&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=271LkXJ8niM" target="_self"&gt;Embed Power BI Report for Customers using App Own Concept and Service Principal&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=z6kFtJVhgjQ" target="_self"&gt;Embed Power BI Report for Customers using App Owns Data and Master User&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In addition, the followings are the ones which has similar problem with yours. Hope they can help you.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/49037233/operation-returned-an-invalid-status-code-unauthorized" target="_self"&gt;Operation returned an invalid status code 'Unauthorized''&lt;/A&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;&lt;SPAN&gt;Based on your description, I assumed that you are using the Access token for Power BI users (user owns data) approach. I would recommend you use&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A style="font-family: inherit; background-color: #ffffff;" href="https://jwt.io/" rel="nofollow noreferrer" target="_blank"&gt;https://jwt.io/&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;to decode the access_token after successfully invoked&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;authContext.AcquireTokenAsync&lt;/CODE&gt;&lt;SPAN&gt;. Make sure the&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;aud&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;is&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;&lt;A href="https://analysis.windows.net/powerbi/api" target="_blank"&gt;https://analysis.windows.net/powerbi/api&lt;/A&gt;&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;and check the permissions scope property&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;scp&lt;/CODE&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;For&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://msdn.microsoft.com/en-us/library/mt243842.aspx" rel="nofollow noreferrer" target="_blank"&gt;Get Groups&lt;/A&gt;, the required scope would look as follows:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Required scope&lt;/STRONG&gt;: Group.Read.All or Group.ReadWrite.All or Workspace.Read.All or Workspace.ReadWrite.All&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You could also use fiddler or postman to simulate the request against the get groups endpoint with the access_token received in your WPF application to narrow down this issue.&lt;/P&gt;
&lt;P&gt;Moreover, you could follow&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/register-app" rel="nofollow noreferrer" target="_blank"&gt;Register an application&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to check your Azure AD app and make sure the required delegated permissions to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Power BI Service (Microsoft.Azure.AnalysisServices)&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;API have been correctly configured.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Developer/401-when-accessing-any-Power-BI-API-endpoints/m-p/336493#M9954" target="_self"&gt;401 when accessing any Power BI API endpoints&lt;/A&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;SPAN&gt;I found something that work and documented it (with code) here:&amp;nbsp;&lt;/SPAN&gt;&lt;A style="font-family: inherit; font-size: 16px; background-color: #ffffff;" href="https://bitbucket.org/omnistream/powerbi-api-example" target="_blank" rel="nofollow noopener noreferrer"&gt;https://bitbucket.org/omnistream/powerbi-api-example&lt;/A&gt;
&lt;P&gt;Hopefully it would help other people in need!&lt;/P&gt;
&lt;P&gt;It's not entirely satisfying: I'm notably not too sure why I should use this authentication endpoint instead of the one I found in other documentation, nor why I have to use a username/password on top of the app credentials, especially since it's not a super secure way to do it; I'm concerned it may get deprecated in the future. But it works.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 03:29:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Unauthorized/m-p/2428411#M35252</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-31T03:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Operation returned an invalid status code 'Unauthorized''</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Unauthorized/m-p/2445009#M35415</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/372180"&gt;@WilliamTit&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Whether your problem has been resolved? If yes, could you please mark the helpful post as &lt;STRONG&gt;Answered&lt;/STRONG&gt;? It will help the others in the community find the solution easily if they face the same problem as yours. Thank you.&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 06:18:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Unauthorized/m-p/2445009#M35415</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-04-08T06:18:03Z</dc:date>
    </item>
  </channel>
</rss>

