<?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 Creating an embedded report with a fabric datasource using service principle authentication in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Creating-an-embedded-report-with-a-fabric-datasource-using/m-p/3809618#M51439</link>
    <description>&lt;P&gt;I have an app that displays power bi reports from a workspace.&lt;/P&gt;&lt;P&gt;When I use fabric as a datasource, I get an error in&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var tokenResponse =
                await client.Reports.GenerateTokenAsync(
                    new Guid(SelectedWorkspaceId),
                    new Guid(SelectedReportId),
                    generateTokenRequestParameters);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can get an fabric access token using a service principle, but this doesn't work when passed to Show report&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;  string[] scopes = new string[] { "https://api.fabric.microsoft.com/.default" };

  ConfidentialClientApplicationBuilder confidentialClientAppBuilder =
      ConfidentialClientApplicationBuilder.Create(ClientId)
      .WithClientSecret(ClientSecret)
      .WithAuthority(Authority)
      .WithTenantId(tenantId);

  IConfidentialClientApplication confidentialClientApplication = confidentialClientAppBuilder.Build();

  AuthenticationResult result = await confidentialClientApplication.AcquireTokenForClient(scopes)
      .ExecuteAsync()
      .ConfigureAwait(false);

  
  return result.AccessToken;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Apr 2024 07:07:08 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-04-04T07:07:08Z</dc:date>
    <item>
      <title>Creating an embedded report with a fabric datasource using service principle authentication</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Creating-an-embedded-report-with-a-fabric-datasource-using/m-p/3809618#M51439</link>
      <description>&lt;P&gt;I have an app that displays power bi reports from a workspace.&lt;/P&gt;&lt;P&gt;When I use fabric as a datasource, I get an error in&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var tokenResponse =
                await client.Reports.GenerateTokenAsync(
                    new Guid(SelectedWorkspaceId),
                    new Guid(SelectedReportId),
                    generateTokenRequestParameters);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can get an fabric access token using a service principle, but this doesn't work when passed to Show report&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;  string[] scopes = new string[] { "https://api.fabric.microsoft.com/.default" };

  ConfidentialClientApplicationBuilder confidentialClientAppBuilder =
      ConfidentialClientApplicationBuilder.Create(ClientId)
      .WithClientSecret(ClientSecret)
      .WithAuthority(Authority)
      .WithTenantId(tenantId);

  IConfidentialClientApplication confidentialClientApplication = confidentialClientAppBuilder.Build();

  AuthenticationResult result = await confidentialClientApplication.AcquireTokenForClient(scopes)
      .ExecuteAsync()
      .ConfigureAwait(false);

  
  return result.AccessToken;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 07:07:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Creating-an-embedded-report-with-a-fabric-datasource-using/m-p/3809618#M51439</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-04T07:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating an embedded report with a fabric datasource using service principle authentication</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Creating-an-embedded-report-with-a-fabric-datasource-using/m-p/3812204#M51458</link>
      <description>&lt;P&gt;HI&amp;nbsp;Anonymous&lt;/LI-USER&gt;,&lt;/P&gt;
&lt;P&gt;It seems like you faced the 400 error,&amp;nbsp;this error occurs when a request sent to a website server is incorrect or corrupt, and the server receiving the request can’t understand it.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/19671317/400-bad-request-http-error-code-meaning" target="_blank"&gt;rest - 400 BAD request HTTP error code meaning? - Stack Overflow&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;AFAIK, the root URL of rest API should be &lt;A href="https://api.powerbi.com/v1.0/myorg" target="_blank"&gt;https://api.powerbi.com/v1.0/myorg&lt;/A&gt;. According to your descriptions, it seems like you modify it to &lt;A href="https://api.fabric.microsoft.com/" target="_blank"&gt;https://api.fabric.microsoft.com/&lt;/A&gt; and it did not able to be responded with these requests.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Xiaoxin Sheng&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2024 01:34:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Creating-an-embedded-report-with-a-fabric-datasource-using/m-p/3812204#M51458</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-05T01:34:41Z</dc:date>
    </item>
    <item>
      <title>Re: Creating an embedded report with a fabric datasource using service principle authentication</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Creating-an-embedded-report-with-a-fabric-datasource-using/m-p/3818323#M51586</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; using (var client = new PowerBIClient(
     new Uri("https://api.powerbi.com/"), tokenCredentials))
 {
     var report =
     await client.Reports.GetReportInGroupAsync(
         new Guid(SelectedWorkspaceId),
         new Guid(SelectedReportId));

     var generateTokenRequestParameters =
         new GenerateTokenRequest(accessLevel: TokenAccessLevel.View);

     var tokenResponse =
         await client.Reports.GenerateTokenAsync(
             new Guid(SelectedWorkspaceId),
             new Guid(SelectedReportId),
             generateTokenRequestParameters);

     await Interop.ShowReport(
         JSRuntime,
         PowerBIElement,
         tokenResponse.Token,
         report.EmbedUrl,
         report.Id.ToString());
 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code I'm using to get the token. This is what is producing the error&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2024 07:45:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Creating-an-embedded-report-with-a-fabric-datasource-using/m-p/3818323#M51586</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-08T07:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: Creating an embedded report with a fabric datasource using service principle authentication</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Creating-an-embedded-report-with-a-fabric-datasource-using/m-p/3840453#M51764</link>
      <description>&lt;P&gt;HI&amp;nbsp;Anonymous&lt;/LI-USER&gt;,&lt;/P&gt;
&lt;P&gt;So you mean these processes get the return the error messages that you faced and motion at the above? Have you tried to create a common function to invoke these operations instead of package into the using functions?&lt;/P&gt;
&lt;P&gt;The GC may affect the await processings, perhaps you can add some output trace to confirm these required parameters has correctly generated in your codes processings.&lt;/P&gt;
&lt;P&gt;BTW, are you worked with fabric API? AFAIK, current it seems not support service principal.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/rest/api/fabric/articles/using-fabric-apis" target="_blank"&gt;Microsoft Fabric REST APIs for automation and embedded analytics - Microsoft Fabric REST APIs | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Xiaoxin Sheng&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2024 08:05:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Creating-an-embedded-report-with-a-fabric-datasource-using/m-p/3840453#M51764</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-16T08:05:30Z</dc:date>
    </item>
  </channel>
</rss>

