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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
foxyox
Regular Visitor

How to Refresh Data - if report is built using API Query with an API Bearer token

Hi, 

I built a report using the KnowBe4 reporting API. Everything is working OK and refreshes OK when I hit refresh in my report.

 

Aim

To publish the report and for the data to be refreshed on a schedule

Problem
When I edit the semantic model setting and try and set the refresh interval it prompts me to login to the KnowBe4 URL, it does not seem to provide the option to use the Authorization header option where I would then type "Bearer" followed by a space and then my API token.

Can someone let me know where I am going wrong and how to solve, 

Many thanks

foxyox_0-1753459526217.png

 




1 ACCEPTED SOLUTION
rohit1991
Super User
Super User

Hi @foxyox ,

 

Its because you can set the token directly in your query, but the Power BI Service doesn’t support custom Authorization headers (like “Bearer {token}”) when scheduling a refresh.

 

When you publish to the Service, it only allows certain built-in authentication methods, and there’s no way to manually enter or refresh a Bearer token for the schedule. If your API token is static and never expires, you can sometimes hard-code it in your query, but this isn’t secure or recommended. Most APIs use tokens that expire, which means refresh will break unless your code can automatically get a new token each time. 

 

Best ways to handle this:

  • Custom connector: The most robust fix is building a custom Power Query connector that handles the authentication flow for you. This requires some coding but is fully supported.

  • Azure Data Factory or Logic Apps: Another popular workaround is using an Azure service to pull the API data (with the right authentication), save it to a database or storage, then connect Power BI to that.

  • API keys: If your API supports static API keys, those are much easier to use with scheduled refresh.


Power BI Service can’t schedule refreshes for APIs that need dynamic Bearer tokens unless you build a connector or stage the data elsewhere.


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

View solution in original post

3 REPLIES 3
Royel
Solution Sage
Solution Sage

Hi @foxyox I am agree with @lbendlin you can manage this authentication in power query. Try this to fix in power query https://stackoverflow.com/questions/40753188/google-oauth-refresh-tokens-in-power-query 

rohit1991
Super User
Super User

Hi @foxyox ,

 

Its because you can set the token directly in your query, but the Power BI Service doesn’t support custom Authorization headers (like “Bearer {token}”) when scheduling a refresh.

 

When you publish to the Service, it only allows certain built-in authentication methods, and there’s no way to manually enter or refresh a Bearer token for the schedule. If your API token is static and never expires, you can sometimes hard-code it in your query, but this isn’t secure or recommended. Most APIs use tokens that expire, which means refresh will break unless your code can automatically get a new token each time. 

 

Best ways to handle this:

  • Custom connector: The most robust fix is building a custom Power Query connector that handles the authentication flow for you. This requires some coding but is fully supported.

  • Azure Data Factory or Logic Apps: Another popular workaround is using an Azure service to pull the API data (with the right authentication), save it to a database or storage, then connect Power BI to that.

  • API keys: If your API supports static API keys, those are much easier to use with scheduled refresh.


Power BI Service can’t schedule refreshes for APIs that need dynamic Bearer tokens unless you build a connector or stage the data elsewhere.


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!
lbendlin
Super User
Super User

Your Power Query code is supposed to include the step where you acquire the bearer token, and then the step where you use the token to query the API.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.