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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
v-shex-msft
Community Support
Community Support

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

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

Thanks @v-shex-msft, 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.

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

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

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

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

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors