locked
ADAL token problem when connecting to PowerBI Service via API from powershell RRS feed

  • Question

  • hi, 

    I'm trying to connect to powerBI by using API from powershell.

    this is the code that I'm using:

    $common = $PSScriptRoot + "\common.ps1"
    . $common
    
    ##set parent directory for this file
    #set project setting file
    $parentfDir = Split-Path $PSScriptRoot -Parent 
    $confDir = getFilePath $parentfDir "\json\automation_tools_seting.json"
    
    #get project settings and package parameter
    $conf = loadJsonFile $confDir
    
    $user = $conf.PBI_user
    $pass = $conf.PBI_pass | ConvertTo-SecureString -asPlainText -Force
    
    $credential = New-Object System.Management.Automation.PSCredential ($user, $pass)
    try {
        Connect-PowerBIServiceAccount -Credential $credential
    
        Disconnect-PowerBIServiceAccount
    }
    catch {
       Write-Output "$($_.Exception.Message)"
        
    }

    but it always has an error :
    Connect-PowerBIServiceAccount : Failed to get ADAL token:


    wondering if there's way to fix this problem


    Wednesday, July 17, 2019 2:20 AM

Answers

  • Hi,

    The message is pretty generic and indicates an authentican failure. There could be many reasons for that...

    just curious: what happens if you just enter 

    Connect-PowerBIServiceAccount -Credential (Get-Credential)

    and then enter the credentials, when the promtp appear? Does this work?


    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" where applicable. This helps the community, keeps the forums tidy, and recognizes useful contributions. Thanks!) Blog: https://blog.pohn.ch/ Twitter: @StoyanChalakov

    Wednesday, July 17, 2019 9:28 PM
  • This is a very old and abandoned question. Please do not add new questions to other users issues.

    The issue is not a scripting issue.  Contact MS Support for help with authentication problems.


    \_(ツ)_/

    • Marked as answer by jrvModerator Thursday, October 10, 2019 6:07 PM
    Thursday, October 10, 2019 6:06 PM
    Moderator

All replies

  • Hi,

    The message is pretty generic and indicates an authentican failure. There could be many reasons for that...

    just curious: what happens if you just enter 

    Connect-PowerBIServiceAccount -Credential (Get-Credential)

    and then enter the credentials, when the promtp appear? Does this work?


    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" where applicable. This helps the community, keeps the forums tidy, and recognizes useful contributions. Thanks!) Blog: https://blog.pohn.ch/ Twitter: @StoyanChalakov

    Wednesday, July 17, 2019 9:28 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Lee


    Just do it.

    Wednesday, July 31, 2019 7:43 AM
    Moderator
  • Hi Stoyan

    I'm experiencing the same issue as OP and so I'll respond on his behalf.  Entering in the string you provided and then punching in my org credentials results in the same error.  Below is a sample of the top of the error (the full error is HUGE):

    Connect-PowerBIServiceAccount : Failed to get ADAL token: Unhandled Exception: System.AggregateException: One or more errors occurred. ---> Microsoft.IdentityModel.Clients.ActiveDirectory.AdalException: Device Certificate was not found for Cert Authorities:OU=<GUID Removed by Simon>,CN=MS-Organization-Access,DC=windows,DC=net   at Microsoft.IdentityModel.Clients.ActiveDirectory.Internal.Platform.DeviceAuthHelper.FindCertificateByCertAuthorities(IDictionary`2 challengeData, X509Certificate2Collection certCollection)  

    Thursday, October 10, 2019 5:59 PM
  • This is a very old and abandoned question. Please do not add new questions to other users issues.

    The issue is not a scripting issue.  Contact MS Support for help with authentication problems.


    \_(ツ)_/

    • Marked as answer by jrvModerator Thursday, October 10, 2019 6:07 PM
    Thursday, October 10, 2019 6:06 PM
    Moderator