<?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: Embedding without hard-coding master credentials (app owns data) in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Embedding-without-hard-coding-master-credentials-app-owns-data/m-p/308553#M9094</link>
    <description>&lt;P&gt;No problem.&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://community.fabric.microsoft.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Nov 2017 08:35:48 GMT</pubDate>
    <dc:creator>Eric_Zhang</dc:creator>
    <dc:date>2017-11-22T08:35:48Z</dc:date>
    <item>
      <title>Embedding without hard-coding master credentials (app owns data)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embedding-without-hard-coding-master-credentials-app-owns-data/m-p/296611#M8734</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I've got Power BI Embedded capacity and&amp;nbsp;trying to follow the instructions for the ISV 'app owns data' scenario to get reports into our web app.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;We've hit a bit of a roadblock as it appears there is a requirement for the master credentials to be hard coded within the application. Is this the case? It seems very insecure, there must be a way to authenticate using an access token?&amp;nbsp;We are also struggling to use the samples and&amp;nbsp;API's as they are all .net and our web application is Java.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;from &lt;A href="https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-embedding-content/" target="_blank"&gt;https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-embedding-content/&lt;/A&gt;:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"If you are embedding content for your customers, you will store the credentials for the&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;master&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;account within your application"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Nov 2017 20:20:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embedding-without-hard-coding-master-credentials-app-owns-data/m-p/296611#M8734</guid>
      <dc:creator>MaxW</dc:creator>
      <dc:date>2017-11-05T20:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: Embedding without hard-coding master credentials (app owns data)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embedding-without-hard-coding-master-credentials-app-owns-data/m-p/296951#M8741</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/31677"&gt;@MaxW&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;Hi,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I've got Power BI Embedded capacity and&amp;nbsp;trying to follow the instructions for the ISV 'app owns data' scenario to get reports into our web app.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;We've hit a bit of a roadblock as &lt;STRONG&gt;it appears there is a requirement for the master credentials to be hard coded within the application. Is this the case? It seems very insecure, there must be a way to authenticate using an access token?&amp;nbsp;We are also struggling to use the samples and&amp;nbsp;API's as they are all .net and our web application is Java&lt;/STRONG&gt;.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;from &lt;A href="https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-embedding-content/" target="_blank"&gt;https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-embedding-content/&lt;/A&gt;:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"If you are embedding content for your customers, you will store the credentials for the&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;master&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;account within your application"&lt;BR /&gt;&lt;/SPAN&gt;&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/31677"&gt;@MaxW&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;AFAIK, yes, the master credential has to be hard coded in your application. The way Power BI authenticates is using an access token which is generated with the master credential. If you have concern about the credential security, you could apply some encrypt and decrypt functions in your application instead of hard code the credential as plain text.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In Java, instead of the SDK in .Net, you can reference the &lt;A href="https://msdn.microsoft.com/en-us/library/mt147898.aspx" target="_self"&gt;Power BI REST APIs&lt;/A&gt;&amp;nbsp;and some other &lt;A href="https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-authentication-scenarios#native-application-to-web-api" target="_self"&gt;Azure AD authentication REST APIs&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;eg, you could get the access token with below POST API.&lt;/P&gt;
&lt;PRE&gt;POST /common/oauth2/token HTTP/1.1
Host: login.windows.net 
Content-Type: application/x-www-form-urlencoded

client_id={client id}&amp;amp;grant_type=password&amp;amp;resource=https%3A%2F%2Fanalysis.windows.net%2Fpowerbi%2Fapi&amp;amp;username={your master account}&amp;amp;password={your account password}&lt;/PRE&gt;
&lt;P&gt;With&amp;nbsp;the access token, you can call&amp;nbsp;&lt;A href="https://msdn.microsoft.com/en-us/library/mt634543.aspx" target="_self"&gt;Get Reports&lt;/A&gt;&amp;nbsp;to get reportId&amp;amp;EmbedUrl and&amp;nbsp;&lt;A href="https://msdn.microsoft.com/en-US/library/mt784614.aspx" target="_self"&gt;GenerateToken&lt;/A&gt;&amp;nbsp;to get Embed token for specific reports.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As to embedding, use &lt;A href="https://github.com/Microsoft/PowerBI-JavaScript" target="_self"&gt;Power BI Javascript API&lt;/A&gt;. See a demo in a static HTML.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;lt;html&amp;gt;
&amp;lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="powerbi.js"&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;script type="text/javascript"&amp;gt;
window.onload = function () {
 // Read embed application token from Model
    var accessToken = "embed token"; 
	
    // Read embed URL from Model
    var embedUrl = "embed url";

    // Read dashboard Id from Model
    var embedReportId = "reportid";

    // Get models. models contains enums that can be used.
    var models = window['powerbi-client'].models; 
	 
    var config = {
        type: 'report',
        tokenType: models.TokenType.Embed,
        accessToken: accessToken,
        embedUrl: embedUrl,
        id: embedReportId , 
		settings: {
        filterPaneEnabled: true	
    }		 
    };

    // Get a reference to the embedded dashboard HTML element
    var dashboardContainer = $('#reportContainer')[0] ;

    // Embed the dashboard and display it within the div container.
var reports = powerbi.embed(dashboardContainer, config); 
  
&amp;lt;/script&amp;gt;  
&amp;lt;div id="reportContainer"&amp;gt;&amp;lt;/div&amp;gt; 
&amp;lt;/html&amp;gt;  &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 08:49:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embedding-without-hard-coding-master-credentials-app-owns-data/m-p/296951#M8741</guid>
      <dc:creator>Eric_Zhang</dc:creator>
      <dc:date>2017-11-06T08:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: Embedding without hard-coding master credentials (app owns data)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embedding-without-hard-coding-master-credentials-app-owns-data/m-p/297491#M8754</link>
      <description>&lt;P&gt;Hi Eric,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you this is a very comprehensive and helpful reply. I will pass it on to our app developers and see if there is a way we can satisfy the security concerns.&lt;BR /&gt;&lt;BR /&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 20:35:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embedding-without-hard-coding-master-credentials-app-owns-data/m-p/297491#M8754</guid>
      <dc:creator>MaxW</dc:creator>
      <dc:date>2017-11-06T20:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: Embedding without hard-coding master credentials (app owns data)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embedding-without-hard-coding-master-credentials-app-owns-data/m-p/307261#M9037</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/6971"&gt;@Eric_Zhang&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I finally got the tokens working thanks to your post, but I'm now stuck on the RLS. Maybe I'm misunderstanding how it is supposed to work?&lt;BR /&gt;&lt;BR /&gt;I generate an access token using the master account, then use that token to generate an embed token with a variable username like so:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;{   
    "accessLevel": "View",
    "identities": [     
        {      
            "username": "Org19",
            "roles": [ "OrganisationUser" ],
            "datasets": [ "5f5...0d5f5" ]
        }   
    ] 
} &lt;/PRE&gt;&lt;P&gt;I then have a report with the role "OrganisationUser" and the Organisation table filtered as&amp;nbsp;[OrganisationIdString]=USERNAME()&lt;BR /&gt;&lt;BR /&gt;In the report I have a card showing the measure that is 'User=USERNAME()'&lt;BR /&gt;&lt;BR /&gt;The report runs In the javascript sample &lt;A href="https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html" target="_blank"&gt;https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;but I expect the card to show 'Org19' but instead it shows my master account username.&lt;BR /&gt;&lt;BR /&gt;Am I close or doing this&amp;nbsp;totally wrong?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 23:57:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embedding-without-hard-coding-master-credentials-app-owns-data/m-p/307261#M9037</guid>
      <dc:creator>MaxW</dc:creator>
      <dc:date>2017-11-20T23:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: Embedding without hard-coding master credentials (app owns data)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embedding-without-hard-coding-master-credentials-app-owns-data/m-p/307468#M9052</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/31677"&gt;@MaxW&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I don't have problem generating the RLS token, the username shows what it is passed in the JSON body. Please post more details how you generate the embedded token.&lt;/P&gt;
&lt;PRE&gt;Measure=USERNAME()&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&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/70497i3D0FFF2D2D78DD3F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 06:57:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embedding-without-hard-coding-master-credentials-app-owns-data/m-p/307468#M9052</guid>
      <dc:creator>Eric_Zhang</dc:creator>
      <dc:date>2017-11-21T06:57:47Z</dc:date>
    </item>
    <item>
      <title>Re: Embedding without hard-coding master credentials (app owns data)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embedding-without-hard-coding-master-credentials-app-owns-data/m-p/308141#M9078</link>
      <description>&lt;P&gt;Hi Eric,&lt;BR /&gt;&lt;BR /&gt;I'm so sorry for wasting your time here, I was generating the token using curl and think I had wrapped the JSON incorrectly so it was getting ignored.&amp;nbsp;Everything&amp;nbsp;seems to be working now thank you so much for your help!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 20:28:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embedding-without-hard-coding-master-credentials-app-owns-data/m-p/308141#M9078</guid>
      <dc:creator>MaxW</dc:creator>
      <dc:date>2017-11-21T20:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: Embedding without hard-coding master credentials (app owns data)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embedding-without-hard-coding-master-credentials-app-owns-data/m-p/308553#M9094</link>
      <description>&lt;P&gt;No problem.&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://community.fabric.microsoft.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2017 08:35:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embedding-without-hard-coding-master-credentials-app-owns-data/m-p/308553#M9094</guid>
      <dc:creator>Eric_Zhang</dc:creator>
      <dc:date>2017-11-22T08:35:48Z</dc:date>
    </item>
  </channel>
</rss>

