<?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: Refresh the token in PowerBI Embedded in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Refresh-the-token-in-PowerBI-Embedded/m-p/2554059#M36469</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/314133"&gt;@Chorda&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;In fact, I think they should have similar logic. &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;You can create a similar function with 'if statement' and 'get token' API to get token and expiry date time to stored into global variables. &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Then you can set a loop or timer to compare system time and expiration DateTime and invoke the generate new token function to update the stored tokens to update before the expiry date.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/embedded/embed-customer-app" target="_blank"&gt;Embed Power BI report in a Power BI embedded analytics application for your customers - Power BI | Microsoft Docs&lt;/A&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>Thu, 02 Jun 2022 02:41:10 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-06-02T02:41:10Z</dc:date>
    <item>
      <title>Refresh the token in PowerBI Embedded</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Refresh-the-token-in-PowerBI-Embedded/m-p/2548512#M36427</link>
      <description>&lt;P&gt;I have embedded a Power BI report into my webapp using "Power BI Embedded" (following the model "embed for your customer").&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the token creation, sending them back and forth, works fine. But the token expires within 1-hr. I need to refresh the token it before it expires. Here is how to refresh the token:&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/javascript/api/overview/powerbi/refresh-token#refresh-token-example" target="_blank" rel="noopener nofollow noreferrer"&gt;Refresh the access token in Power BI embedded analytics | Microsoft Docs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;However the KEY to the solution is implementing the function&amp;nbsp;getNewUserAccessToken() .&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;There is already a similar post&amp;nbsp;here&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Developer/How-to-implement-getNewUserAccessToken-function-for-PowerBI/m-p/2161729" target="_blank"&gt;https://community.powerbi.com/t5/Developer/How-to-implement-getNewUserAccessToken-function-for-PowerBI/m-p/2161729&amp;nbsp;&lt;/A&gt;&lt;/SPAN&gt;However, the "accepted solution" in this post works becasue the token acquisition in&amp;nbsp;&lt;SPAN&gt;the Power Platform.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But I'm doing token acquisition via C# code as in standard "embed for your customer" .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What should the C# code look like for&amp;nbsp;function&amp;nbsp;getNewUserAccessToken()&amp;nbsp; in&amp;nbsp;"embed for your customer"?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Help appreciated,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;( cc'ing you guys in case you know something&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;)&lt;/P&gt;</description>
      <pubDate>Mon, 30 May 2022 22:09:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Refresh-the-token-in-PowerBI-Embedded/m-p/2548512#M36427</guid>
      <dc:creator>Chorda</dc:creator>
      <dc:date>2022-05-30T22:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Refresh the token in PowerBI Embedded</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Refresh-the-token-in-PowerBI-Embedded/m-p/2554059#M36469</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/314133"&gt;@Chorda&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;In fact, I think they should have similar logic. &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;You can create a similar function with 'if statement' and 'get token' API to get token and expiry date time to stored into global variables. &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Then you can set a loop or timer to compare system time and expiration DateTime and invoke the generate new token function to update the stored tokens to update before the expiry date.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/embedded/embed-customer-app" target="_blank"&gt;Embed Power BI report in a Power BI embedded analytics application for your customers - Power BI | Microsoft Docs&lt;/A&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>Thu, 02 Jun 2022 02:41:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Refresh-the-token-in-PowerBI-Embedded/m-p/2554059#M36469</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-06-02T02:41:10Z</dc:date>
    </item>
  </channel>
</rss>

