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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
bayeshelsinki
Regular Visitor

Data refresh with Web.Contents and Web API authentication

Hi,

In Power BI Desktop, it is convenient to store tokens securely, when using the Web.contents function by using the ApiKeyName argument. Upon refreshing the data Power BI prompts the token, data is loaded and the token is stored securely outside the .pbix file.

When I publish the report to Power BI service I run into problems if I want to refresh the data. Is the secure storing of tokens only  supported in Power BI desktop and do I need to hardcode the token to my Power Query to enable scheduled refreshes with Web.Contents? The hardcoded tokens approach works with data refreshes in both Desktop and Service, but is not as secure.

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

Hi @bayeshelsinki ,

 

To my knowledge, Power BI service does not support the ApiKeyName option.

You could take a look at this issus for detailed description.

 

In addition, there are several blog posts on how to work around this problem.Hope these help.

 

Web.Contents(), M Functions And Dataset Refresh Errors In Power BI

Dynamic Web.Contents() and Power BI Refresh Errors

Using The “Skip Test Connection” Option For Power BI Data Sources To Avoid Scheduled Refresh Failure...

 

As for the syntax of the workaround, 

you could check this blog to learn more.

Revisiting Dynamic Web.Contents()

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
bayeshelsinki
Regular Visitor

Thanks @v-eqin-msft!

This is a big minus as there is no way to store the tokens securely and they have to be hard-coded into the power query. Anyone that has access to the .pbix file will also get the authentication tokens.

Not necessarily. Maybe you can hard code a token, use it to test the connection, then expire it and then replace it at runtime with a parameterized token that you get from outside of Power BI (via a separate query for example).

 

yeah, sounds crazy. but maybe worth a try.

v-eqin-msft
Community Support
Community Support

Hi @bayeshelsinki ,

 

To my knowledge, Power BI service does not support the ApiKeyName option.

You could take a look at this issus for detailed description.

 

In addition, there are several blog posts on how to work around this problem.Hope these help.

 

Web.Contents(), M Functions And Dataset Refresh Errors In Power BI

Dynamic Web.Contents() and Power BI Refresh Errors

Using The “Skip Test Connection” Option For Power BI Data Sources To Avoid Scheduled Refresh Failure...

 

As for the syntax of the workaround, 

you could check this blog to learn more.

Revisiting Dynamic Web.Contents()

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors