Invalid status code 'Forbidden'
Hi sir, I have run your sample then i got stucked in 2 case:
- I changed clientId, username, password then I got The request body must contain the following parameter: 'client_secret or client_assertion.
- After some researched I found that I should use
var clientCre = new ClientCredential(clientId, clientSecret);This case I already got token. But then got stuck again inusing (var client = new PowerBIClient(new Uri(apiUrl), tokenCredentials)) { var groups = client.Groups.GetGroups(); }. It saidMicrosoft.Rest.HttpOperationException: 'Operation returned an invalid status code 'Forbidden''.
I wonder that this sample is for Native ?
@lamnv5490 I got the same error!
Same error here, I get Forbidden. Why they don't use the same auth metod as for PBI Collections?
@aminebizid You should try Native App and dont forget to grant permission on AAD. if you try .NET Core. You will need to use REST API to get token, they just dont support .NET Core 2.0
@lamnv5490 I added PowerBi Service as required Permission on the principal. Do I need another permessions to make it work?
_clientCredential = new ClientCredential(myClientId, myClientSecret);
authenticationResult = await _authContext.AcquireTokenAsync("https://analysis.windows.net/powerbi/api", _clientCredential);
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(Bearer, _authenticationResult.AccessToken);
var resp = await _httpClient.GetAsync("https://api.powerbi.com/v1.0/myorg/groups");
I get 401
Have you click "Grant Permission"? I missed it once.