<?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: PowerBI-JavaScript setAccessToken doesn't work in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/623802#M18565</link>
    <description>&lt;P&gt;Yes, I got it work.&lt;/P&gt;&lt;P&gt;I get the new token every 55minutes in server and set it in a hidden field.&lt;/P&gt;&lt;P&gt;In client side, set the new token every 56 minutes&lt;BR /&gt;report.setAccessToken(newToken)&lt;/P&gt;</description>
    <pubDate>Thu, 14 Feb 2019 21:36:28 GMT</pubDate>
    <dc:creator>dp001</dc:creator>
    <dc:date>2019-02-14T21:36:28Z</dc:date>
    <item>
      <title>PowerBI-JavaScript setAccessToken doesn't work</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/400904#M11948</link>
      <description>&lt;P&gt;I'm using PowerBI-JavaScript library to embed the dashboard on my website :&lt;/P&gt;&lt;PRE&gt;var config = {
        type: 'dashboard',
        tokenType: models.TokenType.Embed,
        accessToken: accessToken,
        embedUrl: embedUrl,
        id: embedDashboardId
    };

    // 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);&lt;/PRE&gt;&lt;P&gt;I wanna use setAccessToken to update my AccessToken keeping dashboard not expired, so I make function below :&lt;/P&gt;&lt;PRE&gt;function setToken() {
       
        dashboard.setAccessToken("newtoken")
            .then(function (r) {
                console.log(r);
                console.log("Update success!!")
            })
            .catch(function (e) {
                console.error('Error setting access token', e);
            });

    }&lt;/PRE&gt;&lt;P&gt;I can see "Update success!!" on console&amp;nbsp;eventually. But when I use getAccessToken(), AccessToken is same as before. It didn't update my AccessToken!!&lt;/P&gt;&lt;P&gt;Please give me a advise&amp;nbsp;or solution to fix this problem! I would appreciate.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 14:41:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/400904#M11948</guid>
      <dc:creator>bboy81905</dc:creator>
      <dc:date>2018-04-20T14:41:32Z</dc:date>
    </item>
    <item>
      <title>PowerBI-JavaScript setAccessToken doesn't work</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/400906#M11987</link>
      <description>&lt;P&gt;I'm using PowerBI-JavaScript library to embed the dashboard on my website :&lt;/P&gt;&lt;PRE&gt; var config = {
        type: 'dashboard',
        tokenType: models.TokenType.Embed,
        accessToken: accessToken,
        embedUrl: embedUrl,
        id: embedDashboardId
    };

    // 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);&lt;/PRE&gt;&lt;P&gt;I wanna use setAccessToken to update my AccessToken keeping dashboard not expired, so I make function below :&lt;/P&gt;&lt;PRE&gt;    function setToken() {
       
        dashboard.setAccessToken("newtoken")
            .then(function (r) {
                console.log(r);
                console.log("Update success!!")
            })
            .catch(function (e) {
                console.error('Error setting access token', e);
            });

    }&lt;/PRE&gt;&lt;P&gt;I can see "Update success!!" on console&amp;nbsp;eventually. But when I use getAccessToken(), AccessToken is same as before. It didn't update my AccessToken!!&lt;/P&gt;&lt;P&gt;Please give me a advisement or solution to fix this problem! I would appreciate &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 10:18:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/400906#M11987</guid>
      <dc:creator>bboy81905</dc:creator>
      <dc:date>2018-04-20T10:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBI-JavaScript setAccessToken doesn't work</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/401227#M11968</link>
      <description>&lt;P&gt;Hi bboy81905,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How you can see at the code in the lib, when you set the new access token it send it to the service, and aparently does not store your token:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Embed.prototype.setAccessToken = function (accessToken) {
	        var embedType = this.config.type;
	        return this.service.hpm.post('/' + embedType + '/token', accessToken, { uid: this.config.uniqueId }, this.iframe.contentWindow)
	            .then(function (response) {
	            return response.body;
	        })
	            .catch(function (response) {
	            throw response.body;
	        });
	    };&lt;/PRE&gt;&lt;P&gt;And when you call getAccessToken it will return the token wich you provided first in the config object (if it is lazy evaluated, as I think it is):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Embed.prototype.getAccessToken = function (globalAccessToken) {
	        var accessToken = this.config.accessToken || this.element.getAttribute(Embed.accessTokenAttribute) || globalAccessToken;
	        if (!accessToken) {
	            throw new Error("No access token was found for element. You must specify an access token directly on the element using attribute '" + Embed.accessTokenAttribute + "' or specify a global token at: powerbi.accessToken.");
	        }
	        return accessToken;
	    };&lt;/PRE&gt;&lt;P&gt;I think you need to change the code at the "setAccessToken" function and add a line like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;this.config.accessToken = accessToken;&lt;/PRE&gt;&lt;P&gt;It will probably solve your problem but i dont&amp;nbsp; think it is the right way to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 18:48:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/401227#M11968</guid>
      <dc:creator>alexsilvar</dc:creator>
      <dc:date>2018-04-20T18:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBI-JavaScript setAccessToken doesn't work</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/401646#M11979</link>
      <description>&lt;P&gt;Thank you for your answer !!&amp;nbsp; ^^&lt;/P&gt;</description>
      <pubDate>Sun, 22 Apr 2018 12:30:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/401646#M11979</guid>
      <dc:creator>bboy81905</dc:creator>
      <dc:date>2018-04-22T12:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBI-JavaScript setAccessToken doesn't work</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/621221#M18533</link>
      <description>&lt;P&gt;Have you got the solution work?&lt;/P&gt;&lt;P&gt;I have the same problem. The token expires in one hour.&lt;/P&gt;&lt;P&gt;Setting&amp;nbsp;setAccessToken() doesn't work in my report.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 02:23:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/621221#M18533</guid>
      <dc:creator>dp001</dc:creator>
      <dc:date>2019-02-12T02:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBI-JavaScript setAccessToken doesn't work</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/623632#M18564</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/109785"&gt;@dp001&lt;/a&gt;&amp;nbsp;me too did you get it work ?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 16:47:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/623632#M18564</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-14T16:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBI-JavaScript setAccessToken doesn't work</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/623802#M18565</link>
      <description>&lt;P&gt;Yes, I got it work.&lt;/P&gt;&lt;P&gt;I get the new token every 55minutes in server and set it in a hidden field.&lt;/P&gt;&lt;P&gt;In client side, set the new token every 56 minutes&lt;BR /&gt;report.setAccessToken(newToken)&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 21:36:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/623802#M18565</guid>
      <dc:creator>dp001</dc:creator>
      <dc:date>2019-02-14T21:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBI-JavaScript setAccessToken doesn't work</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/626230#M18591</link>
      <description>&lt;P&gt;var report = null;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;window.onload = function () {&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;var accessToken = document.getElementById('MainContent_accessToken').value;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;var config = {&lt;BR /&gt;type: 'report',&lt;BR /&gt;accessToken: accessToken,&lt;BR /&gt;embedUrl: embedUrl,&lt;BR /&gt;id: reportId,&lt;BR /&gt;settings: {&lt;BR /&gt;filterPaneEnabled: false,&lt;BR /&gt;navContentPaneEnabled: true&lt;BR /&gt;}&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;var reportContainer = document.getElementById('reportContainer');&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;report = powerbi.embed(reportContainer, config);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;setTimeout(SetNewToken, 3120000)&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;function refreshToken() {&lt;BR /&gt;var newToken = document.getElementById('MainContent_accessToken').value;&lt;BR /&gt;report.setAccessToken(newToken)&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;function SetNewToken() {&lt;BR /&gt;refreshToken();&lt;BR /&gt;setTimeout(SetNewToken, 3120000)&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 21:47:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/626230#M18591</guid>
      <dc:creator>dp001</dc:creator>
      <dc:date>2019-02-18T21:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBI-JavaScript setAccessToken doesn't work</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/807045#M20945</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to refresh token after 55 mins.&lt;/P&gt;&lt;P&gt;I got the new token by using GenerateTokenAsync() method in c# and passed it to js file and I used setAccessToken(newToken) method there.&lt;BR /&gt;But my embedded report is not getting updated with the new token.&lt;BR /&gt;Can you please tell me how you got the new token from server side?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 15:09:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBI-JavaScript-setAccessToken-doesn-t-work/m-p/807045#M20945</guid>
      <dc:creator>ansh2425</dc:creator>
      <dc:date>2019-10-01T15:09:29Z</dc:date>
    </item>
  </channel>
</rss>

