Forum Discussion

luwa's avatar
luwa
Frequent Visitor
8 years ago
Solved

grant_type must be "password" and app level permissions

Hi all,   I am trying to call PBI REST APIs such as https://api.powerbi.com/v1.0/myorg/groups or delet tows in a dataset. The access token I acuiqred using `grant_type: client_credentials`, and pa...
  • ericleigh007's avatar
    8 years ago

    We use a service account that has access to PowerBI for this.  We have MFA turned on almost all accounts, but off for service accounts.

     

    It apears to be true that one needs the password grant type.

     

    And for extra fun, the AAD library no longer supports it.   "UserCredential" is no lnoger there.

     

    So what you must do is issue a regular old HTTPS POST to the authority URL, and a body like this:

     

                string authBody = $@"
    			grant_type = password
    			&resource ={WebUtility.UrlEncode(resourceString)}
    			&username ={WebUtility.UrlEncode(username)}
    			&password ={WebUtility.UrlEncode(password)}
    			&client_id ={clientId}
                &client_secret={ WebUtility.UrlEncode(secret)}";

    With this information, becuase you're including a client secret, there will be no prompt necessary.

     

    Good luck.

    -e