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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
cboisvert
Regular Visitor

Automated API call blocked by 2FA

Hello everyone!

 

I'm looking to set up a Python script that automates logging into my PowerBI account, navigating to a dashboard, and sharing a screenshot of that dashboard to a Slack channel once every day.
I'm struggling with 2FA, as this prevents me from automating this process. Any advice on how to get around the challenges with 2FA without actually disabling it? 

Thank you!

1 ACCEPTED SOLUTION
Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @cboisvert,

 

You could for example use an Entra Id app registration/service principal to interact with the Power BI api's:

https://learn.microsoft.com/en-us/power-bi/developer/embedded/embed-service-principal

 

Edit: And here are two code samples of that approach:

https://github.com/AntoineDW/powerbi-rest-api-python

https://github.com/areed1192/power-bi-python-api

 

Found in this thread: https://community.fabric.microsoft.com/t5/Developer/Connect-to-Power-BI-API-via-Python/m-p/2302692

 

 



Happy to help out 🙂

I share #PowerAutomate and #SharePointOnline content on my Blog, Bluesky profile or Youtube Channel

View solution in original post

2 REPLIES 2
sangameshks
Helper I
Helper I

@cboisvert Use Selenium with manual 2FA for one-time authentication, but be prepared to refresh the session periodically

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @cboisvert,

 

You could for example use an Entra Id app registration/service principal to interact with the Power BI api's:

https://learn.microsoft.com/en-us/power-bi/developer/embedded/embed-service-principal

 

Edit: And here are two code samples of that approach:

https://github.com/AntoineDW/powerbi-rest-api-python

https://github.com/areed1192/power-bi-python-api

 

Found in this thread: https://community.fabric.microsoft.com/t5/Developer/Connect-to-Power-BI-API-via-Python/m-p/2302692

 

 



Happy to help out 🙂

I share #PowerAutomate and #SharePointOnline content on my Blog, Bluesky profile or Youtube Channel

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.