<?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 Authentication and Read/Write using Javascript API in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Authentication-and-Read-Write-using-Javascript-API/m-p/324672#M9594</link>
    <description>&lt;P&gt;Trying to do something really really simple - but it seems like you have to scale a 100ft wall every step of the way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Background:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) I'd like to use this&amp;nbsp;&lt;A href="https://github.com/Microsoft/PowerBI-JavaScript" target="_blank"&gt;https://github.com/Microsoft/PowerBI-JavaScript&lt;/A&gt; API wrapper to push data / embed PowerBI reports in an &lt;STRONG&gt;"App Owns Data"&lt;/STRONG&gt; scenario, &lt;STRONG&gt;authenticating server-side.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Following this tutorial, but can't get past the first step&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/walkthrough-push-data" target="_blank"&gt;https://docs.microsoft.com/en-us/power-bi/developer/walkthrough-push-data&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Problem:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Before I can even authenticate, need to register an app. Ok. Tried to follow this&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/register-app" target="_blank"&gt;https://docs.microsoft.com/en-us/power-bi/developer/register-app&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, amazingly, the&amp;nbsp;&lt;A href="https://dev.powerbi.com/apps" target="_blank"&gt;dev.powerbi.com/apps&lt;/A&gt;&amp;nbsp;page is broken.&lt;/P&gt;&lt;P&gt;So now, tried to register via the azure portal. I got the ClientID by doing this, but &lt;STRONG&gt;where do I get the ClientSecret, to call the API&amp;nbsp;server side?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Let's assume I have the ClientID and ClientSecret. Trying to follow this tutorial now:&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/get-azuread-access-token" target="_blank"&gt;https://docs.microsoft.com/en-us/power-bi/developer/get-azuread-access-token&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this only has examples using C# auth libraries. And while &lt;A href="https://msdn.microsoft.com/library/mt784614.aspx" target="_blank"&gt;https://msdn.microsoft.com/library/mt784614.aspx&lt;/A&gt; might work for getting Embed Tokens for individual reports etc, &lt;STRONG&gt;I don't think it works for Pushing Data to Datasets.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;So I tried to use this:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-js" target="_blank"&gt;https://github.com/AzureAD/azure-activedirectory-library-for-js&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The closest code sample I can find is&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="pl-smi"&gt;adalAuthenticationServiceProvider&lt;/SPAN&gt;.&lt;SPAN class="pl-en"&gt;init&lt;/SPAN&gt;(
        {
            &lt;SPAN class="pl-c"&gt;// Config to specify endpoints and similar for your app&lt;/SPAN&gt;
            tenant&lt;SPAN class="pl-k"&gt;:&lt;/SPAN&gt; &lt;SPAN class="pl-s"&gt;&lt;SPAN class="pl-pds"&gt;"&lt;/SPAN&gt;52d4b072-9470-49fb-8721-bc3a1c9912a1&lt;SPAN class="pl-pds"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;, &lt;SPAN class="pl-c"&gt;// Optional by default, it sends common&lt;/SPAN&gt;
            clientId&lt;SPAN class="pl-k"&gt;:&lt;/SPAN&gt; &lt;SPAN class="pl-s"&gt;&lt;SPAN class="pl-pds"&gt;"&lt;/SPAN&gt;e9a5a8b6-8af7-4719-9821-0deef255f68e&lt;SPAN class="pl-pds"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;, &lt;SPAN class="pl-c"&gt;// Required&lt;/SPAN&gt;
            &lt;SPAN class="pl-c"&gt;//localLoginUrl: "/login",  // optional&lt;/SPAN&gt;
            &lt;SPAN class="pl-c"&gt;//redirectUri : "your site", optional&lt;/SPAN&gt;
            endpoints&lt;SPAN class="pl-k"&gt;:&lt;/SPAN&gt; endpoints  &lt;SPAN class="pl-c"&gt;// If you need to send CORS api requests.&lt;/SPAN&gt;
        }&lt;BR /&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;but I don't think even this works because there is no ClientSecret being used.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;How do I authenticate to AAD from server-side javascript??&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3&amp;gt;&lt;/STRONG&gt;Let's assume I now have an Access Token , that I can&amp;nbsp; theoretically use with&amp;nbsp;&lt;A href="https://github.com/Microsoft/PowerBI-JavaScript" target="_blank"&gt;https://github.com/Microsoft/PowerBI-JavaScript&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;How do I construct an authenticated API request using that library?&lt;/STRONG&gt; Documentation here&amp;nbsp; &lt;A href="https://powerbi.docs.apiary.io/#introduction/authenticate-with-power-bi" target="_blank"&gt;https://powerbi.docs.apiary.io/#introduction/authenticate-with-power-bi&lt;/A&gt; says to use an Authorization header entry, but that's for a vanilla REST request...what's the syntax for the API wrapper?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure if this process was made intentionally convoluted + lacking in any examples, but I can't imagine how anyone new to this actually uses it. If anyone has any&lt;STRONG&gt; code samples&lt;/STRONG&gt;, esp for the authentication piece, I would be very grateful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated. Thanks!&lt;/P&gt;</description>
    <pubDate>Sat, 16 Dec 2017 23:05:05 GMT</pubDate>
    <dc:creator>sjorg</dc:creator>
    <dc:date>2017-12-16T23:05:05Z</dc:date>
    <item>
      <title>Authentication and Read/Write using Javascript API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Authentication-and-Read-Write-using-Javascript-API/m-p/324672#M9594</link>
      <description>&lt;P&gt;Trying to do something really really simple - but it seems like you have to scale a 100ft wall every step of the way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Background:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) I'd like to use this&amp;nbsp;&lt;A href="https://github.com/Microsoft/PowerBI-JavaScript" target="_blank"&gt;https://github.com/Microsoft/PowerBI-JavaScript&lt;/A&gt; API wrapper to push data / embed PowerBI reports in an &lt;STRONG&gt;"App Owns Data"&lt;/STRONG&gt; scenario, &lt;STRONG&gt;authenticating server-side.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Following this tutorial, but can't get past the first step&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/walkthrough-push-data" target="_blank"&gt;https://docs.microsoft.com/en-us/power-bi/developer/walkthrough-push-data&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Problem:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Before I can even authenticate, need to register an app. Ok. Tried to follow this&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/register-app" target="_blank"&gt;https://docs.microsoft.com/en-us/power-bi/developer/register-app&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, amazingly, the&amp;nbsp;&lt;A href="https://dev.powerbi.com/apps" target="_blank"&gt;dev.powerbi.com/apps&lt;/A&gt;&amp;nbsp;page is broken.&lt;/P&gt;&lt;P&gt;So now, tried to register via the azure portal. I got the ClientID by doing this, but &lt;STRONG&gt;where do I get the ClientSecret, to call the API&amp;nbsp;server side?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Let's assume I have the ClientID and ClientSecret. Trying to follow this tutorial now:&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/get-azuread-access-token" target="_blank"&gt;https://docs.microsoft.com/en-us/power-bi/developer/get-azuread-access-token&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this only has examples using C# auth libraries. And while &lt;A href="https://msdn.microsoft.com/library/mt784614.aspx" target="_blank"&gt;https://msdn.microsoft.com/library/mt784614.aspx&lt;/A&gt; might work for getting Embed Tokens for individual reports etc, &lt;STRONG&gt;I don't think it works for Pushing Data to Datasets.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;So I tried to use this:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-js" target="_blank"&gt;https://github.com/AzureAD/azure-activedirectory-library-for-js&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The closest code sample I can find is&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="pl-smi"&gt;adalAuthenticationServiceProvider&lt;/SPAN&gt;.&lt;SPAN class="pl-en"&gt;init&lt;/SPAN&gt;(
        {
            &lt;SPAN class="pl-c"&gt;// Config to specify endpoints and similar for your app&lt;/SPAN&gt;
            tenant&lt;SPAN class="pl-k"&gt;:&lt;/SPAN&gt; &lt;SPAN class="pl-s"&gt;&lt;SPAN class="pl-pds"&gt;"&lt;/SPAN&gt;52d4b072-9470-49fb-8721-bc3a1c9912a1&lt;SPAN class="pl-pds"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;, &lt;SPAN class="pl-c"&gt;// Optional by default, it sends common&lt;/SPAN&gt;
            clientId&lt;SPAN class="pl-k"&gt;:&lt;/SPAN&gt; &lt;SPAN class="pl-s"&gt;&lt;SPAN class="pl-pds"&gt;"&lt;/SPAN&gt;e9a5a8b6-8af7-4719-9821-0deef255f68e&lt;SPAN class="pl-pds"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;, &lt;SPAN class="pl-c"&gt;// Required&lt;/SPAN&gt;
            &lt;SPAN class="pl-c"&gt;//localLoginUrl: "/login",  // optional&lt;/SPAN&gt;
            &lt;SPAN class="pl-c"&gt;//redirectUri : "your site", optional&lt;/SPAN&gt;
            endpoints&lt;SPAN class="pl-k"&gt;:&lt;/SPAN&gt; endpoints  &lt;SPAN class="pl-c"&gt;// If you need to send CORS api requests.&lt;/SPAN&gt;
        }&lt;BR /&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;but I don't think even this works because there is no ClientSecret being used.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;How do I authenticate to AAD from server-side javascript??&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3&amp;gt;&lt;/STRONG&gt;Let's assume I now have an Access Token , that I can&amp;nbsp; theoretically use with&amp;nbsp;&lt;A href="https://github.com/Microsoft/PowerBI-JavaScript" target="_blank"&gt;https://github.com/Microsoft/PowerBI-JavaScript&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;How do I construct an authenticated API request using that library?&lt;/STRONG&gt; Documentation here&amp;nbsp; &lt;A href="https://powerbi.docs.apiary.io/#introduction/authenticate-with-power-bi" target="_blank"&gt;https://powerbi.docs.apiary.io/#introduction/authenticate-with-power-bi&lt;/A&gt; says to use an Authorization header entry, but that's for a vanilla REST request...what's the syntax for the API wrapper?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure if this process was made intentionally convoluted + lacking in any examples, but I can't imagine how anyone new to this actually uses it. If anyone has any&lt;STRONG&gt; code samples&lt;/STRONG&gt;, esp for the authentication piece, I would be very grateful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated. Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 16 Dec 2017 23:05:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Authentication-and-Read-Write-using-Javascript-API/m-p/324672#M9594</guid>
      <dc:creator>sjorg</dc:creator>
      <dc:date>2017-12-16T23:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: Authentication and Read/Write using Javascript API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Authentication-and-Read-Write-using-Javascript-API/m-p/325660#M9628</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/49863"&gt;@sjorg&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As far as I know, the Power BI JavaScript wrapper is only for embedding purpose. It is not for pushing data at all. As to the "App Owns Data" scenario, it usually requires a &lt;STRONG&gt;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/register-app#register-with-the-power-bi-app-registration-tool" target="_self"&gt;Native app&lt;/A&gt;, s&lt;/STRONG&gt;o no client_secret is involved. For your interest, you can referece&amp;nbsp;&lt;A href="https://www.netiq.com/communities/cool-solutions/creating-application-client-id-client-secret-microsoft-azure-new-portal/" target="_self"&gt;Creating the application Client ID and Client Secret from Microsoft Azure new portal&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get an accesstoken for pushing data,&amp;nbsp;it is the&amp;nbsp;ADAL lib, the github lib you've already known. You can reference sample in @Anonymous&lt;/a&gt;&amp;nbsp;last reply in this &lt;A href="https://community.powerbi.com/t5/Developer/403-Error-when-trying-to-access-REST-API/td-p/296324" target="_self"&gt;thread&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, why all in Javascript? For "App Owns Data", it actually uses a master account. While using ADAL, you'll have to do the authentication through a pop up log-on window. I'm not an expert on ADAL however I doubt ADAL would support to do the authentication by passing username&amp;amp;&amp;amp;password instead of the pop-up. Even it supports, I don't think it is a good idea to hard coded the username&amp;amp;&amp;amp;password in your Javascript or Web page, it is definitely risky.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2017 01:32:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Authentication-and-Read-Write-using-Javascript-API/m-p/325660#M9628</guid>
      <dc:creator>Eric_Zhang</dc:creator>
      <dc:date>2017-12-19T01:32:54Z</dc:date>
    </item>
  </channel>
</rss>

