<?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: Generating report embed token return 401 in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Generating-report-embed-token-return-401/m-p/201883#M6440</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/4365"&gt;@calm1kov&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Howewer the response from access token has all necessary scopes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Access token request's response:&lt;/P&gt;
&lt;PRE&gt;{
    "token_type": "Bearer",
    &lt;FONT size="5"&gt;"scope": "Dashboard.Read.All Dataset.Read.All Group.Read Report.ReadWrite.All",&lt;/FONT&gt;
    "expires_in": "3600",
    "ext_expires_in": "0",
    "expires_on": "1498449876",
    "not_before": "1498445976",
    "resource": "https://analysis.windows.net/powerbi/api",
    "access_token": "eyJ0eXAiO...T3DwV2XQ",
    "refresh_token": "AQABAAAAAABnfiG-...-Wzb-zqO1ExGK31EUyy8gAA"
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Application was created through&amp;nbsp;&lt;A href="https://dev.powerbi.com/apps" target="_self"&gt;https://dev.powerbi.com/apps&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="5"&gt;&lt;STRONG&gt;- All permissions was set in AD&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/4365"&gt;@calm1kov&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Based on my test, that scope is sufficient to request a dashboard embedtoken however not for a report embedtoken.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When all permissions are checked, I get the accesstoken with scope like&lt;/P&gt;
&lt;PRE&gt;    "token_type": "Bearer",
    "scope": "Content.Create Dashboard.Read.All Data.Alter_Any Dataset.Read.All Dataset.ReadWrite.All Group.Read Group.Read.All Metadata.View_Any Report.Read.All Report.ReadWrite.All",&lt;/PRE&gt;
&lt;P&gt;When did you check all permissions in AD? &amp;nbsp;Even though I'm not an expert on AAD, I think&amp;nbsp;you have the same "re-prompt the user with the consent page" in &lt;A href="https://stackoverflow.com/questions/39582510/azure-ad-prompt-user-admin-to-re-consent-after-changing-application-permissions" target="_self"&gt;this thread&lt;/A&gt;. The the permission doesn't change at all even though you already set all permission before re-consent. I'm not aware of how to re-consent, however you could&amp;nbsp;follow below steps to grant all permission initially and it indeed works to request a report embedtoken base on my test.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1.Register a app&amp;nbsp;&lt;SPAN&gt;through&amp;nbsp;&lt;/SPAN&gt;&lt;A title="" href="https://dev.powerbi.com/apps" target="_self" rel="nofollow noopener noreferrer"&gt;https://dev.powerbi.com/apps&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;2.Check all permissions and save.&lt;/P&gt;
&lt;P&gt;3.Grant permission.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/47660i386DFA49F86D647C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;4. Request accesstoken with this client_id.&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;</description>
    <pubDate>Tue, 27 Jun 2017 07:09:54 GMT</pubDate>
    <dc:creator>Eric_Zhang</dc:creator>
    <dc:date>2017-06-27T07:09:54Z</dc:date>
    <item>
      <title>Generating report embed token return 401</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Generating-report-embed-token-return-401/m-p/200917#M6414</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Following &lt;A href="https://channel9.msdn.com/Shows/Data-Exposed/Setting-up-and-Getting-Started-with-Power-BI-Embedded" target="_self"&gt;this tutorial&lt;/A&gt;&amp;nbsp;and&amp;nbsp; &lt;A href="https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-embedding/" target="_self"&gt;Embedding with non-Power BI users&lt;/A&gt;, I already successfully embeded dashboard for non-Power BI users.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've used the approach of retrieving access token for master account (pro) with username and password.&lt;/P&gt;&lt;P&gt;Then generating embed token with access token.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to say that there is lack of API documentation for non C# developers.&lt;/P&gt;&lt;P&gt;Also when there is error - no error code given or explanation. Not developer friendly at all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is simple examle of embeding Dashboard with PHP:&lt;/P&gt;&lt;LI-SPOILER&gt;&lt;PRE&gt;&amp;lt;?php

$ch_access_token = curl_init();

$oauth_data = [
    'grant_type' =&amp;gt; 'password',
    'username' =&amp;gt; 'master-usern@domain.onmicrosoft.com',
    'password' =&amp;gt; '123456',
    'client_id' =&amp;gt; 'x7957710-04xc-1a345-1234-097d273f4az2',
    'resource' =&amp;gt; 'https://analysis.windows.net/powerbi/api',
];

curl_setopt($ch_access_token, CURLOPT_URL, 'https://login.microsoftonline.com/common/oauth2/token');
curl_setopt($ch_access_token, CURLOPT_POST, 1);
curl_setopt($ch_access_token, CURLOPT_POSTFIELDS, http_build_query($oauth_data));

// receive server response ...
curl_setopt($ch_access_token, CURLOPT_RETURNTRANSFER, true);

$server_output_access_token = curl_exec($ch_access_token);

curl_close($ch_access_token);

$token_data = json_decode($server_output_access_token, true);

$access_token = $token_data['access_token'] ?? '';

if (!$access_token) {
    die('NA');
}

$ch_entity_token = curl_init();

$json_body = [
    'accessLevel' =&amp;gt; 'View'
];

$group_id = 'ad567a8z-088x-1234-3456-112255a2a5a2';
$entity_id = 'zb567a8z-088x-1234-448-33775a2a5a2b';

curl_setopt($ch_entity_token, CURLOPT_URL,
    "https://api.powerbi.com/v1.0/myorg/groups/{$group_id}/dashboards/{$entity_id}/GenerateToken"
);
curl_setopt($ch_entity_token, CURLOPT_POST, 1);
curl_setopt($ch_entity_token, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json; charset=utf-8',
    "Authorization: Bearer {$access_token}"
]);
curl_setopt($ch_entity_token, CURLOPT_POSTFIELDS, json_encode($json_body));

// receive server response ...
curl_setopt($ch_entity_token, CURLOPT_RETURNTRANSFER, true);

$server_output_dashboard_token = curl_exec($ch_entity_token);

curl_close($ch_entity_token);


$entity_token_data = json_decode($server_output_dashboard_token, true);

if (!isset($entity_token_data['token'])) {
    die('NA');
}

?&amp;gt;
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8"/&amp;gt;
    &amp;lt;title&amp;gt;Test page&amp;lt;/title&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1"&amp;gt;
    &amp;lt;script
            src="https://code.jquery.com/jquery-3.2.1.min.js"
            integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
            crossorigin="anonymous"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script src="js/powerbi.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;style&amp;gt;
        html {
            height: 100%;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body style="height: 100%"&amp;gt;
&amp;lt;div id="dashboardContainer" style="height: 100%"&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;script&amp;gt;
    // Read embed application token from Model
    var accessToken = "&amp;lt;?=$entity_token_data['token']?&amp;gt;";

    // Read dashboard Id from Model
    var embedEntityId = "&amp;lt;?=$entity_id?&amp;gt;";

    // Read embed URL from Model
    var embedUrl = 'https://app.powerbi.com/dashboardEmbed';

    // Get models. models contains enums that can be used.
    var models = window['powerbi-client'].models;

    // Embed configuration used to describe the what and how to embed.
    // This object is used when calling powerbi.embed.
    // This also includes settings and options such as filters.
    // You can find more information at https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details.
    var config = {
        type: 'dashboard',
        tokenType: models.TokenType.Embed,
        accessToken: accessToken,
        embedUrl: embedUrl,
        id: embedEntityId
    };

    // Get a reference to the embedded dashboard HTML element
    var dashboardContainer = $('#dashboardContainer')[0];

    // Embed the dashboard and display it within the div container.
    var dashboard = powerbi.embed(dashboardContainer, config);
&amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;/LI-SPOILER&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;So far so good. Dashboard embeded. True fullstack I am.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lets copy-paste above code, replace dashboard with report and we will have report embeded you would say.&lt;/P&gt;&lt;P&gt;Well, maybe with another API's but not with microsoft lol.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is implementation of report embed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-SPOILER&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;?php

$ch_access_token = curl_init();

$oauth_data = [
    'grant_type' =&amp;gt; 'password',
    'username' =&amp;gt; 'master-usern@domain.onmicrosoft.com',
    'password' =&amp;gt; '123456',
    'client_id' =&amp;gt; 'x7957710-04xc-1a345-1234-097d273f4az2',
    'resource' =&amp;gt; 'https://analysis.windows.net/powerbi/api',
];

curl_setopt($ch_access_token, CURLOPT_URL, 'https://login.microsoftonline.com/common/oauth2/token');
curl_setopt($ch_access_token, CURLOPT_POST, 1);
curl_setopt($ch_access_token, CURLOPT_POSTFIELDS, http_build_query($oauth_data));

// receive server response ...
curl_setopt($ch_access_token, CURLOPT_RETURNTRANSFER, true);

$server_output_access_token = curl_exec($ch_access_token);

curl_close($ch_access_token);

$token_data = json_decode($server_output_access_token, true);

$access_token = $token_data['access_token'] ?? '';

if (!$access_token) {
    die('NA');
}

$ch_entity_token = curl_init();

$json_body = [
    'accessLevel' =&amp;gt; 'View'
];

$group_id = 'ad567a8z-088x-1234-3456-112255a2a5a2';
$entity_id = 'zb567a8z-088x-1234-448-33775a2a5a2b';

curl_setopt($ch_entity_token, CURLOPT_URL,
    "https://api.powerbi.com/v1.0/myorg/groups/{$group_id}/reports/{$entity_id}/GenerateToken"
);
curl_setopt($ch_entity_token, CURLOPT_POST, 1);
curl_setopt($ch_entity_token, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json; charset=utf-8',
    "Authorization: Bearer {$access_token}"
]);
curl_setopt($ch_entity_token, CURLOPT_POSTFIELDS, json_encode($json_body));

// receive server response ...
curl_setopt($ch_entity_token, CURLOPT_RETURNTRANSFER, true);

$server_output_report_token = curl_exec($ch_entity_token);

curl_close($ch_entity_token);

$entity_token_data = json_decode($server_output_report_token, true);

if (!isset($entity_token_data['token'])) {
    die('NA');
}

?&amp;gt;
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8"/&amp;gt;
    &amp;lt;title&amp;gt;Test page&amp;lt;/title&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1"&amp;gt;
    &amp;lt;script
            src="https://code.jquery.com/jquery-3.2.1.min.js"
            integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
            crossorigin="anonymous"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script src="js/powerbi.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;style&amp;gt;
        html {
            height: 100%;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body style="height: 100%"&amp;gt;
&amp;lt;div id="reportContainer" style="height: 100%"&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;script&amp;gt;
    // Read embed application token from Model
    var accessToken = "&amp;lt;?=$entity_token_data['token']?&amp;gt;";

    // Read report Id from Model
    var embedEntityId = "&amp;lt;?=$entity_id?&amp;gt;";

    // Read embed URL from Model
    var embedUrl = 'https://app.powerbi.com/reportEmbed';

    // Get models. models contains enums that can be used.
    var models = window['powerbi-client'].models;

    // Embed configuration used to describe the what and how to embed.
    // This object is used when calling powerbi.embed.
    // This also includes settings and options such as filters.
    // You can find more information at https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details.
    var config = {
        type: 'report',
        tokenType: models.TokenType.Embed,
        accessToken: accessToken,
        embedUrl: embedUrl,
        id: embedEntityId
    };

    // Get a reference to the embedded report HTML element
    var reportContainer = $('#reportContainer')[0];

    // Embed the report and display it within the div container.
    var report = powerbi.embed(reportContainer, config);
&amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI-SPOILER&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Generate embed token for report return &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;401 Unauthorized&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Howewer the response from access token has all necessary scopes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Access token request's response:&lt;/P&gt;&lt;PRE&gt;{
    "token_type": "Bearer",
    "scope": "Dashboard.Read.All Dataset.Read.All Group.Read Report.ReadWrite.All",
    "expires_in": "3600",
    "ext_expires_in": "0",
    "expires_on": "1498449876",
    "not_before": "1498445976",
    "resource": "https://analysis.windows.net/powerbi/api",
    "access_token": "eyJ0eXAiO...T3DwV2XQ",
    "refresh_token": "AQABAAAAAABnfiG-...-Wzb-zqO1ExGK31EUyy8gAA"
}&lt;/PRE&gt;&lt;P&gt;Embed token request (return 401):&lt;/P&gt;&lt;PRE&gt;POST /v1.0/myorg/groups/ad567a8z-088x-1234-3456-112255a2a5a2/reports/zb567a8z-088x-1234-448-33775a2a5a2b/GenerateToken HTTP/1.1
Host: api.powerbi.com
Content-Type: application/json; charset=utf-8
Authorization: Bearer eyJ0eXAiO...T3DwV2XQ

{"accessLevel": "View", "allowSaveAs": false}&lt;/PRE&gt;&lt;P&gt;Few more details:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- I have pro license (trial)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Report is part of&amp;nbsp;group(workspace)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://ip1.i.lithium.com/35b6688d13b4f019bd161874574b53643a37146c/687474703a2f2f692e696d6775722e636f6d2f6c546e59537a4f2e706e67" border="0" alt="" width="226" height="200" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Application was created through&amp;nbsp;&lt;A href="https://dev.powerbi.com/apps" target="_self"&gt;https://dev.powerbi.com/apps&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- All permissions was set in AD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://ip1.i.lithium.com/14e81e2c9830d92dfbea0936c0ca78b2daa7bcce/687474703a2f2f692e696d6775722e636f6d2f777a39666554482e706e67" border="0" alt="" width="806" height="322" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any 5 cents appresiated.&lt;/P&gt;&lt;P&gt;Regards.&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;</description>
      <pubDate>Mon, 26 Jun 2017 03:47:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Generating-report-embed-token-return-401/m-p/200917#M6414</guid>
      <dc:creator>calm1kov</dc:creator>
      <dc:date>2017-06-26T03:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: Generating report embed token return 401</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Generating-report-embed-token-return-401/m-p/201883#M6440</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/4365"&gt;@calm1kov&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Howewer the response from access token has all necessary scopes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Access token request's response:&lt;/P&gt;
&lt;PRE&gt;{
    "token_type": "Bearer",
    &lt;FONT size="5"&gt;"scope": "Dashboard.Read.All Dataset.Read.All Group.Read Report.ReadWrite.All",&lt;/FONT&gt;
    "expires_in": "3600",
    "ext_expires_in": "0",
    "expires_on": "1498449876",
    "not_before": "1498445976",
    "resource": "https://analysis.windows.net/powerbi/api",
    "access_token": "eyJ0eXAiO...T3DwV2XQ",
    "refresh_token": "AQABAAAAAABnfiG-...-Wzb-zqO1ExGK31EUyy8gAA"
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Application was created through&amp;nbsp;&lt;A href="https://dev.powerbi.com/apps" target="_self"&gt;https://dev.powerbi.com/apps&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="5"&gt;&lt;STRONG&gt;- All permissions was set in AD&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/4365"&gt;@calm1kov&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Based on my test, that scope is sufficient to request a dashboard embedtoken however not for a report embedtoken.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When all permissions are checked, I get the accesstoken with scope like&lt;/P&gt;
&lt;PRE&gt;    "token_type": "Bearer",
    "scope": "Content.Create Dashboard.Read.All Data.Alter_Any Dataset.Read.All Dataset.ReadWrite.All Group.Read Group.Read.All Metadata.View_Any Report.Read.All Report.ReadWrite.All",&lt;/PRE&gt;
&lt;P&gt;When did you check all permissions in AD? &amp;nbsp;Even though I'm not an expert on AAD, I think&amp;nbsp;you have the same "re-prompt the user with the consent page" in &lt;A href="https://stackoverflow.com/questions/39582510/azure-ad-prompt-user-admin-to-re-consent-after-changing-application-permissions" target="_self"&gt;this thread&lt;/A&gt;. The the permission doesn't change at all even though you already set all permission before re-consent. I'm not aware of how to re-consent, however you could&amp;nbsp;follow below steps to grant all permission initially and it indeed works to request a report embedtoken base on my test.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1.Register a app&amp;nbsp;&lt;SPAN&gt;through&amp;nbsp;&lt;/SPAN&gt;&lt;A title="" href="https://dev.powerbi.com/apps" target="_self" rel="nofollow noopener noreferrer"&gt;https://dev.powerbi.com/apps&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;2.Check all permissions and save.&lt;/P&gt;
&lt;P&gt;3.Grant permission.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/47660i386DFA49F86D647C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;4. Request accesstoken with this client_id.&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;</description>
      <pubDate>Tue, 27 Jun 2017 07:09:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Generating-report-embed-token-return-401/m-p/201883#M6440</guid>
      <dc:creator>Eric_Zhang</dc:creator>
      <dc:date>2017-06-27T07:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: Generating report embed token return 401</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Generating-report-embed-token-return-401/m-p/394307#M11747</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to reproduce this part on C# to manage row level security with php code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;GenerateTokenRequest generateTokenRequestParameters;
                    // This is how you create embed token with effective identities
                    if (!string.IsNullOrEmpty(username))
                    {
                        var rls = new EffectiveIdentity(username, new List&amp;lt;string&amp;gt; { report.DatasetId });
                        if (!string.IsNullOrWhiteSpace(roles))
                        {
                            var rolesList = new List&amp;lt;string&amp;gt;();
                            rolesList.AddRange(roles.Split(','));
                            rls.Roles = rolesList;
                        }
                        // Generate Embed Token with effective identities.
                        generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view", identities: new List&amp;lt;EffectiveIdentity&amp;gt; { rls });
                    }
                    else
                    {
                        // Generate Embed Token for reports without effective identities.
                        generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view");
                    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2018 13:04:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Generating-report-embed-token-return-401/m-p/394307#M11747</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-04-13T13:04:52Z</dc:date>
    </item>
  </channel>
</rss>

