<?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: authentication trought javascript in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/authentication-trought-javascript/m-p/21041#M331</link>
    <description>&lt;P&gt;We've (our org.) just finished implementing this very recently.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While I may not be able to share the code with you, I could at least try to share the architecture, setup and packages used. Bear with me and I'll get back to you with something.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;J&lt;/P&gt;</description>
    <pubDate>Sun, 28 Feb 2016 22:53:53 GMT</pubDate>
    <dc:creator>JasonDunbar</dc:creator>
    <dc:date>2016-02-28T22:53:53Z</dc:date>
    <item>
      <title>authentication trought javascript</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/authentication-trought-javascript/m-p/20212#M312</link>
      <description>&lt;P&gt;Hi everyone!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;anyone knows how to make the authentication process by javascript, because&amp;nbsp;the example of the documentation is done in C#. If someone has something would be helpful! thanks&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 13:29:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/authentication-trought-javascript/m-p/20212#M312</guid>
      <dc:creator>alexanderg</dc:creator>
      <dc:date>2016-02-23T13:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: authentication trought javascript</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/authentication-trought-javascript/m-p/21012#M328</link>
      <description>&lt;P&gt;Hi, I have done this using Google Apps Script, which is basically Javascript.&lt;BR /&gt;I am not a developer, so I am sure there are better/different ways, but it works, and maybe it will point you in the right direction.&lt;BR /&gt;To get a valid refresh token I have to manually login once.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;function pbiInitialAuth(){
var base = "https://login.windows.net/common/oauth2/authorize";
var rtype = "?response_type=code";
var clientID = "&amp;amp;client_id=" + pbiClientID();
var resource = "&amp;amp;resource=https://analysis.windows.net/powerbi/api&amp;amp;redirect_uri=http://localhost:13526/Redirect";
var clientSecret = "&amp;amp;client_secret=" + pbiClientSecret();
var url = base + rtype + clientID + resource + clientSecret;
Logger.log(url);
}&lt;/PRE&gt;&lt;P&gt;The url variable contains a URL that you can&amp;nbsp;open in Firefox&amp;nbsp;and&amp;nbsp;enter your login details.&lt;BR /&gt;The URL you will be redirected to contains a parameter &amp;amp;code=... This is the refresh token.&lt;BR /&gt;Once you have that, you can automatically get new access tokens by using something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;function pbiAccessToken(){
  
  var code = pbiRefreshTokenValue();
  var clientID = pbiClientID();
  var clientSecret = pbiClientSecret();
  var url = "https://login.microsoftonline.com/common/oauth2/token";
  var redirect = "http://localhost:13526/Redirect";
  
  var payload =
   {
     "client_id" : clientID,
     "client_secret" : clientSecret,
     "code": code,
     "grant_type": "authorization_code",
     "redirect_uri": redirect
   };
  
  
  var headers = {
    'Content-Type': 'application/x-www-form-urlencoded'
  };
  
  
  var options = {
    'method': 'post',
    'headers': headers,
    'payload': payload
  };
  
  var response = UrlFetchApp.fetch(url, options);
  var data = JSON.parse(response);
  return data.access_token;
}&lt;/PRE&gt;&lt;P&gt;Hope that helps, it works for me.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Feb 2016 09:37:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/authentication-trought-javascript/m-p/21012#M328</guid>
      <dc:creator>fso</dc:creator>
      <dc:date>2016-02-28T09:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: authentication trought javascript</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/authentication-trought-javascript/m-p/21041#M331</link>
      <description>&lt;P&gt;We've (our org.) just finished implementing this very recently.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While I may not be able to share the code with you, I could at least try to share the architecture, setup and packages used. Bear with me and I'll get back to you with something.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;J&lt;/P&gt;</description>
      <pubDate>Sun, 28 Feb 2016 22:53:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/authentication-trought-javascript/m-p/21041#M331</guid>
      <dc:creator>JasonDunbar</dc:creator>
      <dc:date>2016-02-28T22:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: authentication trought javascript</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/authentication-trought-javascript/m-p/21161#M341</link>
      <description>&lt;P&gt;Hi, &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/2095"&gt;@fso﻿&lt;/a&gt;&amp;nbsp;thanks for your reply is very helpful. I am in the same situation as you because I'm not a developer, but I understand that your first function creates the link to go to the login site and enter the login credentials for get&amp;nbsp;the access token. but my question is how do to save the access token generated in a variable?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Feb 2016 19:44:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/authentication-trought-javascript/m-p/21161#M341</guid>
      <dc:creator>alexanderg</dc:creator>
      <dc:date>2016-02-29T19:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: authentication trought javascript</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/authentication-trought-javascript/m-p/21162#M342</link>
      <description>&lt;P&gt;thanks &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/585"&gt;@JasonDunbar﻿&lt;/a&gt;, any contribution would be very useful!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Feb 2016 19:47:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/authentication-trought-javascript/m-p/21162#M342</guid>
      <dc:creator>alexanderg</dc:creator>
      <dc:date>2016-02-29T19:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: authentication trought javascript</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/authentication-trought-javascript/m-p/21179#M343</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/5049"&gt;@alexanderg﻿&lt;/a&gt;, once you successfully&amp;nbsp;logged in, you get redirected to a url that contains a parameter &amp;amp;code=...&lt;BR /&gt;This code&amp;nbsp;after the equal symbol is the refresh token. I just manually copy it and store it hardcoded in a variable like&lt;/P&gt;&lt;PRE&gt;var refreshToken = "AAAAbbbCCC-aaaa-ssss--dddd";&lt;/PRE&gt;&lt;P&gt;I do not have a programmatic solution to this, but also found that&amp;nbsp;since you can request new access tokens with that refresh token,&amp;nbsp;I never had to re-enter the code again. So for me, it just keeps working.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Feb 2016 21:54:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/authentication-trought-javascript/m-p/21179#M343</guid>
      <dc:creator>fso</dc:creator>
      <dc:date>2016-02-29T21:54:27Z</dc:date>
    </item>
  </channel>
</rss>

