Can't get client-credentials access token to authorize Power BI
Make sure that your app that you registered with AAD has the read write all datasets permission. That should solve the problem.
This is not an answer but one step forward in the debug process. I think the resource for which the token is requested should be "https://analysis.windows.net/powerbi/api". I've seen these in multiple references; one of them is linked below. Even after changing this, I still get a 403. As the OP mentioned if we use the accessToken from the powerBI portal, everything works.
So I tried this with my own app, the following command works (for me): curl -vv -X GET https://api.powerbi.com/v1.0/myorg/datasets -H"Authorization: Bearer ey....qqqq" BTW, the extra "v" after -v seems redundant. So what I can conclude is that your application is missing the required permissions to call Power BI's APIs. One thing you might try is grab one of our samples, create a new application in AAD for it, and then see if the authorization token works for it. Here's a good one to try: https://github.com/PowerBI/Integrate-a-tile-into-an-app
Select Subscription in azure automation
Azure Worker Role Scaling
Registering Two templates with Notification hub and send Notifications
DNS: Azure Server <-> SRV record (Godaddy)<-> Windows 2012 Domain Controller
Azure scalable architecture design
Looking for clarity on Event Hubs vs Topics in Azure Service Bus
How to provision multiple Azure VMs with DSC
Creating Azure Search
Set the max size of Particular.ServiceControl queue in azure
Update app.config on Azure worker role start up
can nlog configuration be set within azure worker role cloudconfiguration files
App.config transformations for multiple worker roles in Azure
Is it possible for the same worker to listen to 2 different subscriptions for different topics
Authenticating machine using Azure AD
Is there a way to specify a machine key for Azure Websites without specifying it in the web.config?
Windows Puppet Agent does not connect to Puppet Enterprise Master