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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Anonymous
Not applicable

How to disable multi factor authentication to use POwer BI REST API

Hi,

 

I am running a powershell script to get the refresh history of all pbi reports of respective workspaces.

Problem: I need to run the script manually, I mention here manually because whenever I run the script it ask me to validate my Microsoft account by entering the pin code (multi-factor authentication). Due to this I am not able to automate the script. I don’t know if it is possible to get authentication token without validating the account or to disable multi-factor authentication. Any suggestion would be really helpful.

Below is the code to Get authentication token:

 

$clientId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

# Calls the Active Directory Authentication Library (ADAL) to authenticate against AAD

 

function GetAuthToken

{

    $adal = "${env:ProgramFiles}\WindowsPowerShell\Modules\AzureRM.profile\5.3.2\Microsoft.IdentityModel.Clients.ActiveDirectory.dll"

   

    $adalforms = "${env:ProgramFiles}\WindowsPowerShell\Modules\AzureRM.profile\5.3.2\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll"

 

    [System.Reflection.Assembly]::LoadFrom($adal) | Out-Null

 

    [System.Reflection.Assembly]::LoadFrom($adalforms) | Out-Null

 

    $redirectUri = "https://oauth.powerbi.com/PBIAPIExplorer"

 

    $resourceAppIdURI = "https://analysis.windows.net/powerbi/api"

 

    $authority = "https://login.microsoftonline.com/common/oauth2/authorize";

 

    $authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority

 

    $authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto")

 

    return $authResult

}

 

# Get the auth token from AAD

$token = GetAuthToken

 

Thanks in advanced

5 REPLIES 5
Anonymous
Not applicable

Have you tried using Service Principal/App Registration via AAD? Make sure you assign PowerBI API Permissions for the registration and then you can get an access token for the registration

Thanks for reply.

Yes, I had tried out service principal way earlier, when didn't have powerbi pro account. And, it hadn't work earlier.

Which is why, I had purchase powerBI pro.

 

I don't recall the actual error now, but somewhere it was related to not able to generate access token.

 

For now, I got unblocked by disabling multi factor authentication using following:

https://community.powerbi.com/t5/Service/Disabling-multi-factor-authentication-for-power-bi/m-p/1087...

piper
Frequent Visitor

Had you succeeded in disabling multi factor authentication for power bi rest api?

Anonymous
Not applicable

@piper,

 

Thank you for reply, unfortunately no.

 

 

I am also stucked with same issue since couple of days.

Can you share what work around you had used to get things working?

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

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.