Forum Discussion
programmatic data refresh using api
- Anonymous9 years ago
Thanks for the response Eric_Zhang, it let me know that what I was trying to achieve could be done. I did some more digging and was able to modify the function in the PS script to use supplied credentials:
function GetAuthToken { $adal = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.dll" $adalforms = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll" [System.Reflection.Assembly]::LoadFrom($adal) | Out-Null [System.Reflection.Assembly]::LoadFrom($adalforms) | Out-Null $redirectUri = "https://login.live.com/oauth20_desktop.srf" $resourceAppIdURI = "https://analysis.windows.net/powerbi/api" $authority = "https://login.windows.net/common/oauth2/authorize"; $userName = "[email protected]" $password = "MyPW" $creds = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential" -ArgumentList $userName,$password $authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority $authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $creds) return $authResult }Obviously I won't be hardcoding these credentials in the script but for testing purposes it works!
EDIT: it looks like my code block has been invaded with emoji's. If anyone is wondering you would replace the emoji with a colon ":" and the letter "P".
This really helped me to skip SSO authentication step.
I have this error message. And I have download and replace with older version of dll files but I still get same error. Can anyone help? Thanks in advance.
Method invocation failed because [Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext] does not contain a method named 'AcquireToken'.
- duncfair8 years agoHelper IV
same