<?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: Powerbi Embed - user owns data - react application - with msal access token not working in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Powerbi-Embed-user-owns-data-react-application-with-msal-access/m-p/2801361#M38932</link>
    <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/447919"&gt;@roen83&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;If the issue only appears when you use MSAL method to get tokens, it means current this mode may not be compatible with get token functions.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&amp;gt;&amp;gt;And when I console.log the response from instance.acquireTokenSilent(), I only see these scopes:&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Please check the permission and scope settings first to confirm you have enough permission to process the operation steps:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/embedded/embed-tokens?tabs=embed-for-customers" target="_blank" rel="noopener"&gt;Understand the permission tokens needed for embedding a Power BI application - Power BI | Microsoft Learn&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Sep 2022 01:40:41 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-09-28T01:40:41Z</dc:date>
    <item>
      <title>Powerbi Embed - user owns data - react application - with msal access token not working</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Powerbi-Embed-user-owns-data-react-application-with-msal-access/m-p/2799244#M38912</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have setup a react app with msal authentication, and would like to embed a PowerBI report in it using the same msal token.&lt;/P&gt;&lt;P&gt;As specified in the title, it is a "user owns data" scenario, my users will have PowerBI Pro access, and I have a tenant for my organization.&lt;/P&gt;&lt;P&gt;I have set up :&lt;/P&gt;&lt;P&gt;- index.js with the MsalProvider&lt;/P&gt;&lt;P&gt;- App.js:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function App() { 
const { instance, accounts } = useMsal(); 
const [accessToken, setAccessToken] = useState(null); 
function RequestProfileData() { 
  const request = { ...loginRequest, account: accounts[0], }; 
  // Silently acquires an access token 
  instance 
    .acquireTokenSilent(request) 
    .then((response) =&amp;gt; { setAccessToken(response.accessToken); }) 
    .catch((e) =&amp;gt; { 
      instance.acquireTokenPopup(request).then((response) =&amp;gt; { 
        setAccessToken(response.accessToken); 
      }); 
    }); 
  } 
  useEffect(()=&amp;gt;{ 
    RequestProfileData() 
  },[]) 
  return ( 
    &amp;lt;PageLayout&amp;gt; 
      &amp;lt;AuthenticatedTemplate&amp;gt; 
        &amp;lt;PowerbiReport accessToken={accessToken}/&amp;gt; 
      &amp;lt;/AuthenticatedTemplate&amp;gt; 
    &amp;lt;/PageLayout&amp;gt; 
  ); }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-PowerbiReport.js:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export default function PowerBIReport(props) {
  let reportId = "&amp;lt;my report id&amp;gt;";
  let embedUrl = "https://app.powerbi.com/reportEmbed?reportId=&amp;lt;my report id&amp;gt;&amp;amp;groupId=&amp;lt;the workspace id&amp;gt;&amp;amp;w=2&amp;amp;config=&amp;lt;config code from app.powerbi&amp;gt;"

  return (
    &amp;lt;&amp;gt;
      &amp;lt;AuthenticatedTemplate&amp;gt;
        &amp;lt;PowerBIEmbed
          embedConfig={{
            type: "report",
            id: reportId,
            embedUrl,
            accessToken: props.accessToken,
            tokenType: models.TokenType.Aad,
            settings: {
              panes: {
                filters: {
                  expanded: false,
                  visible: false,
                },
              },
            },
          }}
          eventHandlers={
            new Map([
              [
                "loaded",
                function () {
                  console.log("Report loaded");
                },
              ],
              [
                "rendered",
                function () {
                  console.log("Report rendered");
                },
              ],
              [
                "error",
                function (event) {
                  console.log(event.detail);
                },
              ],
            ])
          }
          cssClassName={"report-style-class"}
          getEmbeddedComponent={(embeddedReport) =&amp;gt; {
            window.report = embeddedReport;
          }}
        /&amp;gt;
      &amp;lt;/AuthenticatedTemplate&amp;gt;
    &amp;lt;/&amp;gt;
  );
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- the authConfig.js used by the msal library and App.js for "loginRequest":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export const msalConfig = {
    auth: {
      clientId: "&amp;lt;the app client id&amp;gt;",
      authority: "https://login.microsoftonline.com/&amp;lt;my tenant id&amp;gt;",
      redirectUri: "http://localhost:3000/",
    },
    cache: {
      cacheLocation: "localStorage", // This configures where your cache will be stored
      storeAuthStateInCookie: false, // Set this to "true" if you are having issues on IE11 or Edge
    }
  };
  
  // Add scopes here for ID token to be used at Microsoft identity platform endpoints.
  export const loginRequest = {
   scopes: ["User.Read","https://analysis.windows.net/powerbi/api/Report.Read.All","https://analysis.windows.net/powerbi/api/Dataset.Read.All"]
  };&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see I use powerbi-client and powerbi-client-react, and it actually works when I manually copy a right accessToken that I got from the powerBi service (as done in this video: &lt;A href="https://youtu.be/A5KFY5Jh1Uc?t=464" target="_blank"&gt;https://youtu.be/A5KFY5Jh1Uc?t=464&lt;/A&gt;), but not when I use the props.accessToken from my App.js.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone ready to help, please?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 09:10:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Powerbi-Embed-user-owns-data-react-application-with-msal-access/m-p/2799244#M38912</guid>
      <dc:creator>roen83</dc:creator>
      <dc:date>2022-09-27T09:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: Powerbi Embed - user owns data - react application - with msal access token not working</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Powerbi-Embed-user-owns-data-react-application-with-msal-access/m-p/2799302#M38914</link>
      <description>&lt;P&gt;And when I console.log the response from instance.acquireTokenSilent(), I only see these scopes:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="roen83_0-1664270547650.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/793735i62461DBD446E23B5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="roen83_0-1664270547650.png" alt="roen83_0-1664270547650.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 09:22:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Powerbi-Embed-user-owns-data-react-application-with-msal-access/m-p/2799302#M38914</guid>
      <dc:creator>roen83</dc:creator>
      <dc:date>2022-09-27T09:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: Powerbi Embed - user owns data - react application - with msal access token not working</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Powerbi-Embed-user-owns-data-react-application-with-msal-access/m-p/2801361#M38932</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/447919"&gt;@roen83&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;If the issue only appears when you use MSAL method to get tokens, it means current this mode may not be compatible with get token functions.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&amp;gt;&amp;gt;And when I console.log the response from instance.acquireTokenSilent(), I only see these scopes:&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Please check the permission and scope settings first to confirm you have enough permission to process the operation steps:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/embedded/embed-tokens?tabs=embed-for-customers" target="_blank" rel="noopener"&gt;Understand the permission tokens needed for embedding a Power BI application - Power BI | Microsoft Learn&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 01:40:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Powerbi-Embed-user-owns-data-react-application-with-msal-access/m-p/2801361#M38932</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-09-28T01:40:41Z</dc:date>
    </item>
  </channel>
</rss>

