I need to develop an API that when invoked via an endpoint will run an automatic data gathering service and add the results to a PowerBI Streaming Dataset, yet I can't seem to be able to achieve authorization.
Using .NET Core.
I've followed the tutorials to register my App with the AAD, however the ADAL Library doesn't seem to support the authentication suggested for the native app.
This is the code I'm running to get the auth token:
var clientCredential = new ClientCredential(clientID, clientSecret);
var authContext = new AuthenticationContext(authorityUri);
var authResult = await authContext.AcquireTokenAsync(resourceUri, clientCredential);
var token = authResult.AccessToken;
I ran into the same exact issue when setting up my embedded proof of concept. The solution that worked for me was that the user account credential needed to be made an admin of the workspace I was accessing. When I originally added the account I just made it a Member and received 403's. Once I changed it to an admin everything worked properly.
I just tested creating such a request and indeed I received an access token and a refresh token.
There are downsides, ADAL does token refreshment management whilst using this approach would require one to implement their own. (Or just request a new access token for each request).
Thank you for your insight, this might save a lot of people running into the same problem.
I ended up discovering another approach which I've used, and it's simpler, nonetheless I'm accepting yours as a solution as it does, indeed, solve the problem.
About the path I took: I discovered, in my PowerBI's streaming dataset settings, a unique "push url" which allows you to push data to said dataset without bothering with authorization/authentication overhead, as the link per se does the authorization part.
Once again, thank you for your really interesting code snippet!