Forum Discussion
KEMKEM
2 years agoRegular Visitor
How to use the Power Bi Rest Api without the refreshtoken?
I have a powershell script which is using the Power Bi Rest Api. For the authentication they use some strange solution. They capture the refresh token from the browser and save it in a txt file. Than...
KEMKEM
2 years agoRegular Visitor
Hi lbendlin Do you have more info? Maybe some link to a tutorial or blog? Or some code snipped?
lbendlin
2 years agoSuper User
for example
# Calls the Active Directory Authentication Library (ADAL) to authenticate against AAD
function GetAuthToken
{
if(-not (Get-Module AzureRm.Profile)) {
Import-Module AzureRm.Profile
}
$clientId = "xxx"
$redirectUri = "urn:ietf:wg:oauth:2.0:oob"
$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