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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
SilverSN95
Regular Visitor

Dynamic API token in report data source?

Hello,

 

I have a report that I am embedding in our web application, which I accomplished by following the App owns Data documentation, and this piece works fine.

 

The data source for this report is a web call to an API that we own and a user token is required in the HTTP header when calling this API. What I would like to do is dynamically change the API token in the data source specification based on the user who is logged in to our web application. The user is known in the C# code where the embed configuration is generated. On the powerBI side, I have also successfully moved the API token to a parameter that I can change and then refresh to see the appropriate data for that token. Is there any way to pass our API token with the embed config to the report so that it pulls data from the web API using that dynamic token?

 

Thanks.

5 REPLIES 5
Anonymous
Not applicable

HI @SilverSN95,

 

I'd like to suggest you add an api interface to return available access token, then modify your query to add variable steps to invoke that api and store access token string.

 

After these steps, use above variable string as parameter from next operations. 

 

If not, I'd like to suggest you add similar functions to your service.

 

Regards,

Xiaoxin Sheng

Thanks @Anonymous, I'll look into your suggestion. I have an API interface I can call to get the users token, but I need to pass that a user ID. Is there some way for me to pass that information into powerBI or would I also need to get that Id value somehow in the query?

 

Also, I wanted to ask if this use-case is even feasible with a large number of users. These users would be accessing the same embedded report, but the report would use different data sources based on their API token. If these users are trying to access the report at the same time, does this cause any issue for powerBI?

 

Thanks again.

Anonymous
Not applicable

HI @SilverSN95,

 

Maybe you can try to create a template with query parameter user id and publish this report to power bi service as a template content pack.


Then your users can get content pack from service and use user id to generate their own report and dashboard.

Author template content packs in Power BI

 

I think above feature will suitable for your scenario.

 

Regards,

Xiaoxin Sheng

This sounds like a good solution if users are internal powerBI users, but unless I am mistaken this wouldnt work in an embedded situation where the users are clients of our webapp and they are viewing a report embedded in the webapp. Are there ways for an embedded app to access a content pack and create a report programmatically for the client?

 

Thanks

Anonymous
Not applicable

HI @SilverSN95,

 

Unfortunately, current template content pack not works on your scenario.

 

I can only suggest you to create mapping table with username and userid, then enabled RLS feature based on username function.

RLS with UserName()

 

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.