<?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: Automatic refresh of Access Token doesn't work in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Automatic-refresh-of-Access-Token-doesn-t-work/m-p/2510549#M36059</link>
    <description>&lt;P&gt;The following example from documentation is what I used as a template for writing my function:&lt;/P&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="etsygankov_0-1652358338684.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/713665i0A0DD4778087CD43/image-size/medium?v=v2&amp;amp;px=400" role="button" title="etsygankov_0-1652358338684.png" alt="etsygankov_0-1652358338684.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Do you know if "return token" is a string or a type? If a type, is there documentation on what that type should be?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Thu, 12 May 2022 12:27:17 GMT</pubDate>
    <dc:creator>etsygankov</dc:creator>
    <dc:date>2022-05-12T12:27:17Z</dc:date>
    <item>
      <title>Automatic refresh of Access Token doesn't work</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Automatic-refresh-of-Access-Token-doesn-t-work/m-p/2503182#M36003</link>
      <description>&lt;P&gt;I am "emedding for organization" and trying to use the automatic refresh of access token described &lt;A href="https://docs.microsoft.com/en-us/javascript/api/overview/powerbi/refresh-token" target="_self"&gt;here&amp;nbsp;&lt;/A&gt;by providing eventHooks.accessTokenProvider.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code that does embedding (notice accessTokenProvider and getNewToken implementation):&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;&lt;LI-CODE lang="javascript"&gt;let getNewToken = async function () {
            
    var result = await $.ajax({
        type: "POST",
        url: "/gettoken"
    });

    return result.Token;
}

let config = {
    type: type,
    tokenType: models.TokenType.Aad,
    accessToken: common.accessToken,
    embedUrl: embedUrl,
    id: embedId,
    settings: settings,
    eventHooks: {
        accessTokenProvider: getNewToken
    }
};&lt;/LI-CODE&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;&lt;P&gt;Report loads fine and then I see periodic calls to /powerbi/refresh/subscribe in Fiddler. They complete with HTTP 200.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After some time, the access token expires, and I can see that PowerBI calls my getNewToken function and that the new refresh token is being returned -- the Chrome debugger shows the updated access token on line "return result.Token".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But subsequent calls to /powerbi/refresh/subscribe still have &lt;STRONG&gt;the old access token in Authorization: Bearer and fail with HTTP 401.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anybody know why the updated access token returned from accessTokenProvider is not being used for further ajax calls to PowerBI?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any working examples of implementing accessTokenProvider?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2022 23:06:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Automatic-refresh-of-Access-Token-doesn-t-work/m-p/2503182#M36003</guid>
      <dc:creator>etsygankov</dc:creator>
      <dc:date>2022-05-09T23:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic refresh of Access Token doesn't work</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Automatic-refresh-of-Access-Token-doesn-t-work/m-p/2509502#M36042</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/378599"&gt;@etsygankov&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;I'm not so sure if the issue is caused by the compatibility of the ajax function and accessTokenProvider, have you tried to use other types of functions instead?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;In addition, you can also take a look at the following document if it helps:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="https://docs.microsoft.com/en-us/javascript/api/overview/powerbi/refresh-token" target="_blank"&gt;Refresh the access token in Power BI embedded analytics | Microsoft Docs&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 06:21:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Automatic-refresh-of-Access-Token-doesn-t-work/m-p/2509502#M36042</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-05-12T06:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic refresh of Access Token doesn't work</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Automatic-refresh-of-Access-Token-doesn-t-work/m-p/2510549#M36059</link>
      <description>&lt;P&gt;The following example from documentation is what I used as a template for writing my function:&lt;/P&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="etsygankov_0-1652358338684.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/713665i0A0DD4778087CD43/image-size/medium?v=v2&amp;amp;px=400" role="button" title="etsygankov_0-1652358338684.png" alt="etsygankov_0-1652358338684.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Do you know if "return token" is a string or a type? If a type, is there documentation on what that type should be?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 12:27:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Automatic-refresh-of-Access-Token-doesn-t-work/m-p/2510549#M36059</guid>
      <dc:creator>etsygankov</dc:creator>
      <dc:date>2022-05-12T12:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic refresh of Access Token doesn't work</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Automatic-refresh-of-Access-Token-doesn-t-work/m-p/2565604#M36568</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/378599"&gt;@etsygankov&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;The token should be a variable defined with string type in the function and used to get the token string from API response.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 06:20:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Automatic-refresh-of-Access-Token-doesn-t-work/m-p/2565604#M36568</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-06-08T06:20:27Z</dc:date>
    </item>
  </channel>
</rss>

