Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
gcanelon
Frequent Visitor

Token expiring in Power BI embedded (error 403)

Hello community. We are trying to embed a Power BI report using the ReactJS framework and npm installator with the following configuration:

 

     

<Report
      

      

        tokenType="Aad"
      

      

        accessToken="H4s...sc2V9fQ=="
      

      

        embedUrl="https://app.powerbi.com/reportEmbed?reportId=6300f419-XXXX-XXXX-a55e-723f417a3f2b"
      

      

        embedId="6300f419-XXXX-XXXX-a55e-723f417a3f2b"
      

      

        reportMode="View"
      

      

        datasetId={datasetId}
      

      

        groupId={groupId}
      

      

        extraSettings={extraSettings}
      

      

        permissions="View"
      

      

        style={reportStyle}
      

      

        />
      

     
      

      

   Where datasetId and group Id are delared in the extraSettings as follows:

  

 const extraSettings = {
        

        

          filterPaneEnabled: false,
        

        

          navContentPaneEnabled: false,
        

        

          hideErrors: false
        

        

         };
        

     

 The problem is that, althout it initially works fine, after a while I get a error 403 when loading the report. I obtained the accessToken via postman and also using this post  

https://api.powerbi.com/v1.0/myorg/GenerateToken in the documentation located at

https://docs.microsoft.com/en-us/rest/api/power-bi/embedtoken/generatetoken#code-try-0

 

Is it possible to create some sort of API inside mi project to automatically generate an accessToken, with the Power BI Bearer Token as it expires?

 

Thanks in advance for your help.      

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @gcanelon,

You can consider storage the resulting token string and expired date(expiration field) to variables or session and modify yours generate token function to add if statement to compare current date time and cache variables.
After these steps, your invoke token function will force check the expiry date from caches and regenerate the token if they expired.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

HI @gcanelon,

You can consider storage the resulting token string and expired date(expiration field) to variables or session and modify yours generate token function to add if statement to compare current date time and cache variables.
After these steps, your invoke token function will force check the expiry date from caches and regenerate the token if they expired.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.