<?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: dynamical RLS cause bad token error when embed Power BI content in Salesforce in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/dynamical-RLS-cause-bad-token-error-when-embed-Power-BI-content/m-p/4391308#M59302</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry for the late answer, but could you please try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A title="Link" href="https://learn.microsoft.com/en-us/rest/api/power-bi/embed-token/generate-token#example-of-generating-an-embed-token-for-two-datasets-with-rls-identities-and-a-single-report-with-read-only-permissions.-the-embed-token-lets-you-view-the-report,-which-is-dynamically-bound-to-two-different-datasets." target="_self"&gt;#example-of-generating-an-embed-token-for-two-datasets-with-rls-identities-and-a-single-report-with-read-only-permissions.-the-embed-token-lets-you-view-the-report,-which-is-dynamically-bound-to-two-different-datasets&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 02 Feb 2025 15:01:02 GMT</pubDate>
    <dc:creator>mariussve1</dc:creator>
    <dc:date>2025-02-02T15:01:02Z</dc:date>
    <item>
      <title>dynamical RLS cause bad token error when embed Power BI content in Salesforce</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/dynamical-RLS-cause-bad-token-error-when-embed-Power-BI-content/m-p/4376267#M59151</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are trying to embed our power bi content in salesforce so that customers can login to salesforce with their salesforce credential and see power bi reports instead of login to power bi service using their power bi credential.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It worked well before we implemented the dynamical RLS. Steps taken:&lt;/P&gt;&lt;P&gt;1) create a service principal in Entra, and granted it User.Read permission for Microsoft Graph&lt;/P&gt;&lt;P&gt;2) added this service principal to workspace as admin where the report located. The service principal has access to the dataset as well as the report itself.&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) in the report, added a role, [Email] ==USERNAME() (we also tried USERPRINCIPALNAME())&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error message:&amp;nbsp;&lt;SPAN&gt;DEBUG|GenerateToken API call failed. Status: Bad Request, Body: {"error":{"code":"InvalidRequest","message":"Creating embed token for accessing dataset XXX-XXX-XXX-XXX requires effective identity to be provided"}}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;We tried different codes to pass the identities and roles etc. like directly in the URL or as below:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; "accessLevel": "View",&lt;/P&gt;&lt;P&gt;&amp;nbsp; "identities": [&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; "username": "example@domain.com",&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; "roles": [],&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; "datasets": ["&amp;lt;DatasetId&amp;gt;"]&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; ]&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but still get the same error message.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help or did you encounter similar error message? Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2025 17:39:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/dynamical-RLS-cause-bad-token-error-when-embed-Power-BI-content/m-p/4376267#M59151</guid>
      <dc:creator>TingSun</dc:creator>
      <dc:date>2025-01-22T17:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: dynamical RLS cause bad token error when embed Power BI content in Salesforce</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/dynamical-RLS-cause-bad-token-error-when-embed-Power-BI-content/m-p/4377037#M59154</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;You first need to retrieve the token from the backend:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;I assume you’ve already created a SPN (App user) with the correct access to the workspace and sufficient permissions for the APIs that will be used!&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Then, you need to use the following:&lt;BR /&gt;&lt;STRONG&gt;POST&lt;/STRONG&gt; &lt;CODE&gt;&lt;A href="https://login.microsoftonline.com/&amp;lt;tenantid&amp;gt;/oauth2/token" target="_blank"&gt;https://login.microsoftonline.com/&amp;lt;tenantid&amp;gt;/oauth2/token&lt;/A&gt;&lt;BR /&gt;grant_type: client_credentials &lt;BR /&gt;resource: &lt;A href="https://analysis.windows.net/powerbi/api" target="_blank"&gt;https://analysis.windows.net/powerbi/api&lt;/A&gt; &lt;BR /&gt;client_id: &amp;lt;clientid&amp;gt; &lt;BR /&gt;secret: &amp;lt;secret&amp;gt; &lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;When you run this, you will receive a token. This token should be used in the frontend to provide access to the report and the model:&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;POST&lt;/STRONG&gt; &lt;CODE&gt;&lt;A href="https://api.powerbi.com/v1.0/myorg/GenerateToken" target="_blank"&gt;https://api.powerbi.com/v1.0/myorg/GenerateToken&lt;/A&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt; Remember to include &lt;CODE&gt;Content-Type: application/json&lt;/CODE&gt; in the header.&lt;BR /&gt;&lt;STRONG&gt;Authorization:&amp;nbsp;&lt;/STRONG&gt;Bearer &amp;lt;token from backend call up here&amp;gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Body (JSON):&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{
  "datasets": [
    {
      "id": "&amp;lt;datasetid&amp;gt;"
    }
  ],
  "reports": [
    {
      "id": "&amp;lt;reportid&amp;gt;"
    }
  ],
  "accessLevel": "View",
  "identities": [
    {
      "username": "&amp;lt;username&amp;gt;",
      "roles": [
        "&amp;lt;rolename&amp;gt;"
      ],
      "datasets": [
        "&amp;lt;datasetid&amp;gt;"
      ]
    }
  ],
  "lifetimeInMinutes": 10
}&lt;/LI-CODE&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;That should do the trick! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I recommend using something like Postman to test the process conceptually; it makes it easier to identify where things might go wrong.&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2025 06:26:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/dynamical-RLS-cause-bad-token-error-when-embed-Power-BI-content/m-p/4377037#M59154</guid>
      <dc:creator>mariussve1</dc:creator>
      <dc:date>2025-01-23T06:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: dynamical RLS cause bad token error when embed Power BI content in Salesforce</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/dynamical-RLS-cause-bad-token-error-when-embed-Power-BI-content/m-p/4377204#M59157</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/844825"&gt;@TingSun&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;According to the following official documentation,&amp;nbsp;a&amp;nbsp;&lt;SPAN&gt;username and a role are required w&lt;/SPAN&gt;hen&amp;nbsp;&lt;A style="background-color: #ffffff;" title="https://learn.microsoft.com/en-us/power-bi/developer/embedded/generate-embed-token" href="https://learn.microsoft.com/en-us/power-bi/developer/embedded/generate-embed-token" target="_blank" rel="noreferrer noopener"&gt;generating the embed token&lt;/A&gt;&lt;SPAN&gt;.&amp;nbsp;&lt;/SPAN&gt;For a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;service principal&lt;/STRONG&gt;, token generation fails if don't provide the above info(username and role).&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/embedded/cloud-rls#considerations-and-limitations" target="_self"&gt;Using standard cloud based row-level security with embedded content in Power BI embedded analytics&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vyiruanmsft_0-1737616971933.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1229886iE0D66400DFCE9208/image-size/large?v=v2&amp;amp;px=999" role="button" title="vyiruanmsft_0-1737616971933.png" alt="vyiruanmsft_0-1737616971933.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2025 07:23:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/dynamical-RLS-cause-bad-token-error-when-embed-Power-BI-content/m-p/4377204#M59157</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-01-23T07:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: dynamical RLS cause bad token error when embed Power BI content in Salesforce</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/dynamical-RLS-cause-bad-token-error-when-embed-Power-BI-content/m-p/4380236#M59177</link>
      <description>&lt;P&gt;Thank you for the replies. I will test them out and will let you guys know.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 18:16:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/dynamical-RLS-cause-bad-token-error-when-embed-Power-BI-content/m-p/4380236#M59177</guid>
      <dc:creator>TingSun</dc:creator>
      <dc:date>2025-01-24T18:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: dynamical RLS cause bad token error when embed Power BI content in Salesforce</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/dynamical-RLS-cause-bad-token-error-when-embed-Power-BI-content/m-p/4381064#M59184</link>
      <description>&lt;P&gt;Thank you, Marius. Your code worked like a magic. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Jan 2025 03:15:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/dynamical-RLS-cause-bad-token-error-when-embed-Power-BI-content/m-p/4381064#M59184</guid>
      <dc:creator>TingSun</dc:creator>
      <dc:date>2025-01-26T03:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: dynamical RLS cause bad token error when embed Power BI content in Salesforce</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/dynamical-RLS-cause-bad-token-error-when-embed-Power-BI-content/m-p/4388720#M59265</link>
      <description>&lt;P&gt;Hi There,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have another challenge now. Thanks to the json code provided, we were able to make the API call. We even tried on more complex&amp;nbsp;reports using dynamical RLS, all worked so far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, in real world, our reports are connected to datasets and as soon as we try with the real life reports, we got error message: GenerateToken API call failed. Status: Bad Request, Body: {"error":{"code":"InvalidRequest","message":"Embedding a report with a model which has a Direct Query connection to another model is not supported with V1 embed token"}}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does someone know the possible solution for it? Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2025 19:16:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/dynamical-RLS-cause-bad-token-error-when-embed-Power-BI-content/m-p/4388720#M59265</guid>
      <dc:creator>TingSun</dc:creator>
      <dc:date>2025-01-30T19:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: dynamical RLS cause bad token error when embed Power BI content in Salesforce</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/dynamical-RLS-cause-bad-token-error-when-embed-Power-BI-content/m-p/4391308#M59302</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry for the late answer, but could you please try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A title="Link" href="https://learn.microsoft.com/en-us/rest/api/power-bi/embed-token/generate-token#example-of-generating-an-embed-token-for-two-datasets-with-rls-identities-and-a-single-report-with-read-only-permissions.-the-embed-token-lets-you-view-the-report,-which-is-dynamically-bound-to-two-different-datasets." target="_self"&gt;#example-of-generating-an-embed-token-for-two-datasets-with-rls-identities-and-a-single-report-with-read-only-permissions.-the-embed-token-lets-you-view-the-report,-which-is-dynamically-bound-to-two-different-datasets&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2025 15:01:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/dynamical-RLS-cause-bad-token-error-when-embed-Power-BI-content/m-p/4391308#M59302</guid>
      <dc:creator>mariussve1</dc:creator>
      <dc:date>2025-02-02T15:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: dynamical RLS cause bad token error when embed Power BI content in Salesforce</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/dynamical-RLS-cause-bad-token-error-when-embed-Power-BI-content/m-p/4397004#M59346</link>
      <description>&lt;P&gt;Thanks Marius. We managed to get rid of this direct query error message. However, we have a new challenge, most likely the last one for our project... Some of our reports are complex and are based on more than one datasets. So we have reportID, datasetID (and this datasetID is based on two other semantic models), so we have datasetID2 and datasetID3. We cannot find the right way to pass these 3 dataset ids in our request body. Someone has an idea? what's the syntax for it?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
  "datasets": [
    {
      "id": "&amp;lt;datasetid&amp;gt;"
    }
  ],
  "reports": [
    {
      "id": "&amp;lt;reportid&amp;gt;"
    }
  ],
  "accessLevel": "View",
  "identities": [
    {
      "username": "&amp;lt;username&amp;gt;",
      "roles": [
        "&amp;lt;rolename&amp;gt;"
      ],
      "datasets": [
        "&amp;lt;datasetid&amp;gt;"
      ]
    }
  ],
  "lifetimeInMinutes": 10
}&lt;/PRE&gt;&lt;P&gt;How to passing these 3 dataset ids in the following body?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 19:07:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/dynamical-RLS-cause-bad-token-error-when-embed-Power-BI-content/m-p/4397004#M59346</guid>
      <dc:creator>TingSun</dc:creator>
      <dc:date>2025-02-05T19:07:52Z</dc:date>
    </item>
  </channel>
</rss>

